{
 "metadata": {
  "name": "debugging"
 }, 
 "nbformat": 2, 
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "import numpy as np", 
      "", 
      "#see this on NumPy and broadcasting", 
      "#http://onlamp.com/pub/a/python/2000/09/27/numerically.html?page=1", 
      "", 
      "a = np.array([[1,2,3],[4,5,6]])", 
      "b = np.array( [[1,2], [3,4], [5,6]])", 
      "print a", 
      "print b", 
      "print np.shape(a)", 
      "print np.shape(b)", 
      "a+b"
     ], 
     "language": "python", 
     "outputs": [
      {
       "ename": "ValueError", 
       "evalue": "operands could not be broadcast together with shapes (2,3) (3,2) ", 
       "output_type": "pyerr", 
       "traceback": [
        "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m\n\u001b[0;31mValueError\u001b[0m                                Traceback (most recent call last)", 
        "\u001b[0;32m/Users/amit/software/pgmPy/<ipython-input-2-29fbccd8bef0>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[1;32m     10\u001b[0m \u001b[0;32mprint\u001b[0m \u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mshape\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0ma\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m     11\u001b[0m \u001b[0;32mprint\u001b[0m \u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mshape\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mb\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 12\u001b[0;31m \u001b[0ma\u001b[0m\u001b[0;34m+\u001b[0m\u001b[0mb\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m     13\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m     14\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n", 
        "\u001b[0;31mValueError\u001b[0m: operands could not be broadcast together with shapes (2,3) (3,2) "
       ]
      }, 
      {
       "output_type": "stream", 
       "stream": "stdout", 
       "text": [
        "[[1 2 3]", 
        " [4 5 6]]", 
        "[[1 2]", 
        " [3 4]", 
        " [5 6]]", 
        "(2, 3)", 
        "(3, 2)"
       ]
      }
     ], 
     "prompt_number": 2
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "intersect= np.array( [1,5] )", 
      "B= np.array( [2,5,1] )", 
      "#other_array[first_array == item]", 
      "intersect - B"
     ], 
     "language": "python", 
     "outputs": [
      {
       "ename": "ValueError", 
       "evalue": "operands could not be broadcast together with shapes (2) (3) ", 
       "output_type": "pyerr", 
       "traceback": [
        "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m\n\u001b[0;31mValueError\u001b[0m                                Traceback (most recent call last)", 
        "\u001b[0;32m/Users/amit/software/pgmPy/<ipython-input-16-d257c35b5146>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[1;32m      2\u001b[0m \u001b[0mB\u001b[0m\u001b[0;34m=\u001b[0m \u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0marray\u001b[0m\u001b[0;34m(\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m5\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m      3\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 4\u001b[0;31m \u001b[0mintersect\u001b[0m \u001b[0;34m-\u001b[0m \u001b[0mB\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", 
        "\u001b[0;31mValueError\u001b[0m: operands could not be broadcast together with shapes (2) (3) "
       ]
      }
     ], 
     "prompt_number": 16
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "B[intersect == x for x in ]"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "pyout", 
       "prompt_number": 17, 
       "text": [
        "array([2])"
       ]
      }
     ], 
     "prompt_number": 17
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "x=np.arange(10)", 
      "np.random.shuffle(x)", 
      "y=np.arange(5)", 
      "", 
      "xsorted=np.argsort(x)#return the indices that would sort the array", 
      "print \"x: \", x", 
      "print \"y: \", y", 
      "print \"x[xsorted] \", x[xsorted]", 
      "ypos=np.searchsorted(x[xsorted],y)", 
      "print ypos", 
      "indices=xsorted[ypos]", 
      "print \"indices of y elements in x: \", indices", 
      "#print ", 
      "#print y"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "stream", 
       "stream": "stdout", 
       "text": [
        "x:  [8 0 2 9 5 4 6 1 7 3]", 
        "y:  [0 1 2 3 4]", 
        "x[xsorted]  [0 1 2 3 4 5 6 7 8 9]", 
        "[0 1 2 3 4]", 
        "indices of y elements in x:  [1 7 2 9 5]"
       ]
      }
     ], 
     "prompt_number": 43
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "#see this http://stackoverflow.com/questions/8251541/numpy-for-every-element-in-one-array-find-the-index-in-another-array", 
      "import numpy as np", 
      "intersect=np.array( [1,5])", 
      "B=np.array([2,5,1])", 
      "", 
      "sortedintersect=np.argsort(intersect)#return the indices that would sort the array", 
      "bpos=np.searchsorted(intersect[sortedintersect],B)", 
      "", 
      "yindex=np.take(sortedintersect, bpos, mode='clip')", 
      "print \"yindex: \", yindex", 
      "mask=intersect[yindex] !=B", 
      "print \"mask: \", mask", 
      "", 
      "result=np.ma.array(yindex,mask=mask)", 
      "print 'masked array: ', result", 
      "print result.compressed()"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "stream", 
       "stream": "stdout", 
       "text": [
        "yindex:  [1 1 0]", 
        "mask:  [ True False False]", 
        "masked array:  [-- 1 0]", 
        "[1 0]"
       ]
      }
     ], 
     "prompt_number": 8
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "y = np.ma.array([1, 2, 3], mask = [0, 1, 0])", 
      "print y"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "stream", 
       "stream": "stdout", 
       "text": [
        "[1 -- 3]"
       ]
      }
     ], 
     "prompt_number": 7
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "import numpy as np", 
      "x = np.array([3,5,7,1,9,8,6,6])", 
      "y = np.array([2,1,5,10,100,6])", 
      "", 
      "setX=set(x)", 
      "setY=set(y)", 
      "intersect=np.array( list(setX.intersection(setY)))", 
      "", 
      "print 'intersect ', intersect", 
      "", 
      "index = np.argsort(x) # index of elments in sorted order", 
      "sorted_x = x[index]   #sorted version of original array x", 
      "print 'sorted x ', sorted_x", 
      "print 'index ', index", 
      "sorted_index = np.searchsorted(sorted_x, intersect) #indices where elements of y would be inserted into sorted_x to maintain order", 
      "print 'sorted index ', sorted_index", 
      "yindex = np.take(index, sorted_index, mode=\"clip\")", 
      "print 'yindex ', yindex", 
      "#mask = x[yindex] != y", 
      "", 
      "#result = np.ma.array(yindex, mask=mask)", 
      "#print 'result ', result", 
      "#print 'result compressed ', result.compressed()"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "stream", 
       "stream": "stdout", 
       "text": [
        "intersect  [1 5 6]", 
        "sorted x  [1 3 5 6 6 7 8 9]", 
        "index  [3 0 1 6 7 2 5 4]", 
        "sorted index  [0 2 3]", 
        "yindex  [3 1 6]"
       ]
      }
     ], 
     "prompt_number": 28
    }, 
    {
     "cell_type": "code", 
     "collapsed": true, 
     "input": [
      "def getIndex ( V, I):", 
      "    index=np.argsort(V)", 
      "    sorted_v=V[index]", 
      "    sorted_index=np.searchsorted( sorted_v, I)", 
      "    vindex=np.take(index, sorted_index, mode='clip')", 
      "    #print vindex", 
      "    return vindex.tolist()"
     ], 
     "language": "python", 
     "outputs": [], 
     "prompt_number": 32
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "getIndex( np.array( [2,5,1]), np.array( [ 1,5] ) )"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "pyout", 
       "prompt_number": 33, 
       "text": [
        "[2, 1]"
       ]
      }
     ], 
     "prompt_number": 33
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "getIndex( np.array( [1,5]), np.array( [ 1,5] ) )"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "pyout", 
       "prompt_number": 34, 
       "text": [
        "[0, 1]"
       ]
      }
     ], 
     "prompt_number": 34
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "from itertools import *", 
      "ploidys=[2]", 
      "for p in ploidys:", 
      "    for combo in combinations_with_replacement(['A','C','G','T'],p):", 
      "        print combo"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "stream", 
       "stream": "stdout", 
       "text": [
        "('A', 'A')", 
        "('A', 'C')", 
        "('A', 'G')", 
        "('A', 'T')", 
        "('C', 'C')", 
        "('C', 'G')", 
        "('C', 'T')", 
        "('G', 'G')", 
        "('G', 'T')", 
        "('T', 'T')"
       ]
      }
     ], 
     "prompt_number": 3
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "import itertools", 
      "import numpy as np", 
      "alleles='ACGT'", 
      "genotypes= [ genotype  for genotype in itertools.combinations_with_replacement(alleles, 2) ]", 
      "print genotypes"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "stream", 
       "stream": "stdout", 
       "text": [
        "[('A', 'A'), ('A', 'C'), ('A', 'G'), ('A', 'T'), ('C', 'C'), ('C', 'G'), ('C', 'T'), ('G', 'G'), ('G', 'T'), ('T', 'T')]"
       ]
      }
     ], 
     "prompt_number": 1
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "range(4,0,-1)"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "pyout", 
       "prompt_number": 25, 
       "text": [
        "[4, 3, 2, 1]"
       ]
      }
     ], 
     "prompt_number": 25
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "numAlleles=4", 
      "allelesToGenotypes=np.zeros([numAlleles,numAlleles])", 
      "index=0", 
      "for i in range(numAlleles):", 
      "    for j in range (i,numAlleles):", 
      "        allelesToGenotypes[i, j] = index;", 
      "        index+=1", 
      "for i in range(numAlleles):", 
      "    for j in range(0,i):", 
      "        ", 
      "        allelesToGenotypes[i,j] = allelesToGenotypes[j,i]", 
      "print allelesToGenotypes", 
      "", 
      "numGenotypes= (numAlleles * (numAlleles - 1))/2 + numAlleles", 
      "genotypesToAlleles=np.zeros([numGenotypes,2])", 
      "", 
      "index=0", 
      "for i in range(numGenotypes):", 
      "    for j in range(i,numAlleles):", 
      "        #print i, j", 
      "        genotypesToAlleles[index, :] = [i, j];", 
      "        index+=1", 
      "#print genotypesToAlleles"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "stream", 
       "stream": "stdout", 
       "text": [
        "[[ 0.  1.  2.  3.]", 
        " [ 1.  4.  5.  6.]", 
        " [ 2.  5.  7.  8.]", 
        " [ 3.  6.  8.  9.]]", 
        "[[ 0.  0.]", 
        " [ 0.  1.]", 
        " [ 0.  2.]", 
        " [ 0.  3.]", 
        " [ 1.  1.]", 
        " [ 1.  2.]", 
        " [ 1.  3.]", 
        " [ 2.  2.]", 
        " [ 2.  3.]", 
        " [ 3.  3.]]"
       ]
      }
     ], 
     "prompt_number": 35
    }, 
    {
     "cell_type": "code", 
     "collapsed": true, 
     "input": [
      "from PGMcommon import *"
     ], 
     "language": "python", 
     "outputs": [], 
     "prompt_number": 1
    }, 
    {
     "cell_type": "code", 
     "collapsed": true, 
     "input": [
      "(allelesToGenotypes, genotypesToAlleles)=generateAlleleGenotypeMappers(4)"
     ], 
     "language": "python", 
     "outputs": [], 
     "prompt_number": 39
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "print genotypesToAlleles[1,1]"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "stream", 
       "stream": "stdout", 
       "text": [
        "1.0"
       ]
      }
     ], 
     "prompt_number": 40
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "np.shape(genotypesToAlleles)"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "pyout", 
       "prompt_number": 41, 
       "text": [
        "(10, 2)"
       ]
      }
     ], 
     "prompt_number": 41
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "np.zeros((1,10))"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "pyout", 
       "prompt_number": 43, 
       "text": [
        "array([[ 0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.]])"
       ]
      }
     ], 
     "prompt_number": 43
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "np.prod( (1, np.prod(10)))"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "pyout", 
       "prompt_number": 46, 
       "text": [
        "10"
       ]
      }
     ], 
     "prompt_number": 46
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "from PedigreeFactors import *", 
      "", 
      "print GenotypeAlleleFreqFactor([.1,.5,0,0], 1, 'gregor')"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "stream", 
       "stream": "stdout", 
       "text": [
        "name: gregor", 
        "var: 1", 
        "card: 10", 
        "val: 0.01 0.1 0.0 0.0 0.25 0.0 0.0 0.0 0.0 0.0"
       ]
      }
     ], 
     "prompt_number": 2
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "print g1"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "stream", 
       "stream": "stdout", 
       "text": [
        "<PedigreeFactors.GenotypeAlleleFreqFactor object at 0x101f23810>"
       ]
      }
     ], 
     "prompt_number": 2
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "print "
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "stream", 
       "stream": "stdout", 
       "text": [
        "(2,)"
       ]
      }
     ], 
     "prompt_number": 8
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "alleles=[1.,1.]", 
      "", 
      "np.prod( [ allelefreq[i] for i in alleles ] ) "
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "pyout", 
       "prompt_number": 9, 
       "text": [
        "0.81000000000000005"
       ]
      }
     ], 
     "prompt_number": 9
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "np.prod( [.5,.5] )"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "pyout", 
       "prompt_number": 2, 
       "text": [
        "0.25"
       ]
      }
     ], 
     "prompt_number": 2
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "np.zeros(10)"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "pyout", 
       "prompt_number": 2, 
       "text": [
        "array([ 0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.])"
       ]
      }
     ], 
     "prompt_number": 2
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "import itertools", 
      "import numpy as np", 
      "alleles='ACGT'", 
      "genotypes= [ \"\".join(list(genotype))  for genotype in itertools.combinations_with_replacement(alleles, 2) ]", 
      "print genotypes"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "stream", 
       "stream": "stdout", 
       "text": [
        "['AA', 'AC', 'AG', 'AT', 'CC', 'CG', 'CT', 'GG', 'GT', 'TT']"
       ]
      }
     ], 
     "prompt_number": 3
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "print genotypes.index('AA')", 
      "print genotypes[4]"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "stream", 
       "stream": "stdout", 
       "text": [
        "0", 
        "CC"
       ]
      }
     ], 
     "prompt_number": 4
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "s1= \"\"\" hello word", 
      "foo", 
      "bar", 
      "\"\"\"", 
      "print s1"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "stream", 
       "stream": "stdout", 
       "text": [
        " hello word", 
        "foo", 
        "bar"
       ]
      }
     ], 
     "prompt_number": 9
    }, 
    {
     "cell_type": "code", 
     "collapsed": true, 
     "input": [
      "from PGMcommon import *", 
      "import numpy as np"
     ], 
     "language": "python", 
     "outputs": [], 
     "prompt_number": 11
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "genotypeToIndex(\"CC\",alleles='AC')"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "stream", 
       "stream": "stdout", 
       "text": [
        "['AA', 'AC', 'CC']"
       ]
      }, 
      {
       "output_type": "pyout", 
       "prompt_number": 12, 
       "text": [
        "2"
       ]
      }
     ], 
     "prompt_number": 12
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "indexToGenotype(2,alleles='AC')"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "pyout", 
       "prompt_number": 13, 
       "text": [
        "'CC'"
       ]
      }
     ], 
     "prompt_number": 13
    }, 
    {
     "cell_type": "code", 
     "collapsed": true, 
     "input": [
      "(allelesToGenotypes, genotypesToAlleles)=generateAlleleGenotypeMappers(4)"
     ], 
     "language": "python", 
     "outputs": [], 
     "prompt_number": 14
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "stream", 
       "stream": "stdout", 
       "text": [
        "[[0 1 2 3]", 
        " [1 4 5 6]", 
        " [2 5 7 8]", 
        " [3 6 8 9]]"
       ]
      }
     ], 
     "prompt_number": 15
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "print np.shape(genotypesToAlleles)"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "stream", 
       "stream": "stdout", 
       "text": [
        "(10, 2)"
       ]
      }
     ], 
     "prompt_number": 17
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "from Factor import *", 
      "from FactorOperations import *", 
      "from PedigreeFactors import *", 
      "import itertools", 
      "from collections import defaultdict", 
      "genotypeFactor = Factor( [\"bart\", \"homer\", \"marge\"], [ ], [ ], \"\"\"Bart | Homer, Marge \"\"\" )", 
      "(allelesToGenotypes, genotypesToAlleles) = generateAlleleGenotypeMappers(2)", 
      "", 
      "print genotypesToAlleles", 
      "(ngenos,ploidy)= np.shape(genotypesToAlleles)", 
      "#print allelesToGenotypes", 
      "print ngenos"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "stream", 
       "stream": "stdout", 
       "text": [
        "[[0 0]", 
        " [0 1]", 
        " [1 1]]", 
        "3"
       ]
      }
     ], 
     "prompt_number": 2
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "p1=GenotypeGivenParentsFactor(2,\"bart\",\"homer\",\"marge\",\"\"\"Bart | Homer, Marge \"\"\")", 
      "print p1"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "stream", 
       "stream": "stdout", 
       "text": [
        "name: Bart | Homer, Marge ", 
        "var: bart homer marge", 
        "card: 3 3 3", 
        "val: 1.0 0.0 0.0 0.5 0.5 0.0 0.0 1.0 0.0 0.5 0.5 0.0 0.25 0.5 0.25 0.0 0.5 0.5 0.0 1.0 0.0 0.0 0.5 0.5 0.0 0.0 1.0"
       ]
      }
     ], 
     "prompt_number": 4
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "assignments=IndexToAssignment( np.arange(np.prod(genotypeFactor.getCard())), genotypeFactor.getCard() )-1", 
      "#assignments=assignments.astype(int)", 
      "for z in range( np.prod(genotypeFactor.getCard() ) ):", 
      "    #print 'z: ', z", 
      "    curr_assign= assignments[z]", 
      "    #print 'current assignment: ', curr_assign", 
      "    childAssignment=int(curr_assign[0])", 
      "    ", 
      "    parent1gametes= genotypesToAlleles[curr_assign[1],:]", 
      "    parent2gametes= genotypesToAlleles[curr_assign[2],:]", 
      "    #print 'parental gametes: ', parent1gametes, parent2gametes", 
      "    #print 'child assignment: ', childAssignment", 
      "    #list of tuples containing list of zygote(genotype) tuples", 
      "    zygote_list=list(itertools.product(parent1gametes,parent2gametes))", 
      "    punnet_freq=[  allelesToGenotypes[zygote[0],zygote[1]] for zygote in zygote_list ]", 
      "    histc={}", 
      "    hist=[]", 
      "    for g in range( ngenos):", 
      "        histc[g]=0.", 
      "    for x in punnet_freq:", 
      "        histc[x]+=1.", 
      "    #print histc.values()", 
      "    for g in range (ngenos):", 
      "        hist.append ( histc[g] )", 
      "    #print punnet_freq", 
      "    hist=(np.array ( hist)) /4", 
      "    #print 'hist:', hist", 
      "    #print zygote_list", 
      "    values[z]=hist[childAssignment]", 
      "    #print hist", 
      "    #print \"===\"", 
      "genotypeFactor.setVal( values )", 
      "print genotypeFactor"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "stream", 
       "stream": "stdout", 
       "text": [
        "name: Bart | Homer, Marge ", 
        "var: 3 2 1", 
        "card: 3 3 3", 
        "val: 1.0 0.0 0.0 0.5 0.5 0.0 0.0 1.0 0.0 0.5 0.5 0.0 0.25 0.5 0.25 0.0 0.5 0.5 0.0 1.0 0.0 0.0 0.5 0.5 0.0 0.0 1.0"
       ]
      }
     ], 
     "prompt_number": 137
    }, 
    {
     "cell_type": "code", 
     "collapsed": true, 
     "input": [
      "from collections import defaultdict", 
      "a_list=[(0, 0), (0, 0), (0, 0), (0, 0)]", 
      "kvmap= defaultdict(int)", 
      "for k in a_list:", 
      "    kvmap[k] += 1"
     ], 
     "language": "python", 
     "outputs": [], 
     "prompt_number": 86
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "print kvmap.items()"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "stream", 
       "stream": "stdout", 
       "text": [
        "[((0, 0), 4)]"
       ]
      }
     ], 
     "prompt_number": 87
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "for( zygote,count) in kvmap.items():", 
      "    print zygote, count/4", 
      "    print allelesToGenotypes[zygote[0],zygote[1]]"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "stream", 
       "stream": "stdout", 
       "text": [
        "(0, 0) 1", 
        "0"
       ]
      }
     ], 
     "prompt_number": 61
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "allelesToGenotypes([1,1])"
     ], 
     "language": "python", 
     "outputs": [
      {
       "ename": "TypeError", 
       "evalue": "'numpy.ndarray' object is not callable", 
       "output_type": "pyerr", 
       "traceback": [
        "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m\n\u001b[0;31mTypeError\u001b[0m                                 Traceback (most recent call last)", 
        "\u001b[0;32m/Users/amit/software/pgmPy/PythonNotebooks/<ipython-input-45-eceb98560604>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mallelesToGenotypes\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", 
        "\u001b[0;31mTypeError\u001b[0m: 'numpy.ndarray' object is not callable"
       ]
      }
     ], 
     "prompt_number": 45
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "print allelesToGenotypes"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "stream", 
       "stream": "stdout", 
       "text": [
        "[[0 1]", 
        " [1 2]]"
       ]
      }
     ], 
     "prompt_number": 46
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "genotypesToAlleles(3)"
     ], 
     "language": "python", 
     "outputs": [
      {
       "ename": "TypeError", 
       "evalue": "'numpy.ndarray' object is not callable", 
       "output_type": "pyerr", 
       "traceback": [
        "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m\n\u001b[0;31mTypeError\u001b[0m                                 Traceback (most recent call last)", 
        "\u001b[0;32m/Users/amit/software/pgmPy/PythonNotebooks/<ipython-input-47-2082852e1924>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mgenotypesToAlleles\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m3\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", 
        "\u001b[0;31mTypeError\u001b[0m: 'numpy.ndarray' object is not callable"
       ]
      }
     ], 
     "prompt_number": 47
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "genotypesToAlleles[1,:]"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "pyout", 
       "prompt_number": 48, 
       "text": [
        "array([0, 1])"
       ]
      }
     ], 
     "prompt_number": 48
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "np.shape(allelesToGenotypes)"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "pyout", 
       "prompt_number": 50, 
       "text": [
        "(2, 2)"
       ]
      }
     ], 
     "prompt_number": 50
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "allelesToGenotypes[1,1]"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "pyout", 
       "prompt_number": 60, 
       "text": [
        "2"
       ]
      }
     ], 
     "prompt_number": 60
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "allelesToGenotypes"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "pyout", 
       "prompt_number": 53, 
       "text": [
        "array([[0, 1],", 
        "       [1, 2]])"
       ]
      }
     ], 
     "prompt_number": 53
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "range( np.prod(genotypeFactor.getCard() ) )"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "pyout", 
       "prompt_number": 73, 
       "text": [
        "[0,", 
        " 1,", 
        " 2,", 
        " 3,", 
        " 4,", 
        " 5,", 
        " 6,", 
        " 7,", 
        " 8,", 
        " 9,", 
        " 10,", 
        " 11,", 
        " 12,", 
        " 13,", 
        " 14,", 
        " 15,", 
        " 16,", 
        " 17,", 
        " 18,", 
        " 19,", 
        " 20,", 
        " 21,", 
        " 22,", 
        " 23,", 
        " 24,", 
        " 25,", 
        " 26]"
       ]
      }
     ], 
     "prompt_number": 73
    }, 
    {
     "cell_type": "code", 
     "collapsed": true, 
     "input": [], 
     "language": "python", 
     "outputs": [], 
     "prompt_number": 1
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "\"\"\"\" construct a Bayesian Network representing a pedigree (genotypes & phenotypes) \"\"\"", 
      "from Factor import *", 
      "from FactorOperations import *", 
      "from PedigreeFactors import *", 
      "import itertools", 
      "import numpy as np", 
      "#prob of being effected, given the ith genotype", 
      "#alphaList[i] is the prob of being effected given the ith genotype", 
      "alphaList=[.3,.4,.3]", 
      "#lets just make a simple trio of Homer, Marge, and Bart", 
      "homer=Ped('Simpsons','Homer', '0', '0','1','.')", 
      "marge=Ped('Simpsons','Marge', '0', '0','2','.')", 
      "bart=Ped('Simpsons','Bart', 'Homer', 'Marge','1','.')", 
      "", 
      "print homer", 
      "print marge", 
      "print bart", 
      "#a Pedigree is just a list of individual Ped objects", 
      "simpsonsPedigree=[homer, marge, bart]", 
      "", 
      "totalAlleles=2", 
      "alleleFreq=[.5,.5]", 
      "totalPeople=len(simpsonsPedigree)", 
      "print totalPeople", 
      "totalFactors=totalPeople * 2", 
      "factorList=totalFactors*[None]", 
      "print factorList", 
      "for i in range( totalPeople):", 
      "    print i", 
      "    if simpsonsPedigree[i].isFounder():", 
      "        print simpsonsPedigree[i].getid()", 
      "        factorList[i]=GenotypeAlleleFreqFactor(alleleFreq,simpsonsPedigree[i].getid(),simpsonsPedigree[i].getid())", 
      "        #factorList(i)=genotypeGivenAlleleFreqsFactor(alleleFreqs,i);", 
      "    else:", 
      "        print simpsonsPedigree[i].getParents(), simpsonsPedigree[i].getid()", 
      "        #GenotypeGivenParentsFactor(2,\"bart\",\"homer\",\"marge\",\"\"\"Bart | Homer, Marge \"\"\")", 
      "        factorList[i]=GenotypeGivenParentsFactor(totalAlleles, simpsonsPedigree[i].getid(), simpsonsPedigree[i].getParents()[0], simpsonsPedigree[i].getParents()[1], \"Bart|Homer, Marge\")", 
      "        #genotypeGivenParentsGenotypesFactor(numAlleles, i, parents(2), parents(3) )", 
      "    factorList[i+totalPeople]=PhenotypeGivenGenotypeFactor(alphaList, i, i+totalPeople, \"|\".join([ str(i), str(i+totalPeople)]) );", 
      "print factorList[0:3]"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "stream", 
       "stream": "stdout", 
       "text": [
        "Simpsons\tHomer\t0\t0\t1\t.", 
        "Simpsons\tMarge\t0\t0\t2\t.", 
        "Simpsons\tBart\tHomer\tMarge\t1\t.", 
        "3", 
        "[None, None, None, None, None, None]", 
        "0", 
        "Homer", 
        "1", 
        "Marge", 
        "2", 
        "('Homer', 'Marge') Bart", 
        "[<PedigreeFactors.GenotypeAlleleFreqFactor object at 0x1037b2990>, <PedigreeFactors.GenotypeAlleleFreqFactor object at 0x1017af550>, <PedigreeFactors.GenotypeGivenParentsFactor object at 0x1037b2bd0>]"
       ]
      }
     ], 
     "prompt_number": 1
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "#Family ID", 
      "#Individual ID", 
      "#Paternal ID", 
      "#Maternal ID", 
      "#Sex (1=male; 2=female; other=unknownPhenotype", 
      "", 
      "", 
      "p1=PhenotypeGivenGenotypeFactor([.2,.5,.3],6,3,'6|3')", 
      "print p1"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "stream", 
       "stream": "stdout", 
       "text": [
        "name: 6|3", 
        "var: 6 3", 
        "card: 2 3", 
        "val: 0.2 0.8 0.5 0.5 0.3 0.7"
       ]
      }
     ], 
     "prompt_number": 5
    }, 
    {
     "cell_type": "code", 
     "collapsed": true, 
     "input": [
      "alphaList=[.3,.4,.3]", 
      "values = [x for x in range( np.prod([2,3]))]"
     ], 
     "language": "python", 
     "outputs": [], 
     "prompt_number": 3
    }, 
    {
     "cell_type": "code", 
     "collapsed": true, 
     "input": [
      "ctr=0", 
      "alphas=2*len(alphaList)*[None]", 
      "for i in range(len(alphaList)):", 
      "  alphas[ctr]=alphaList[i];", 
      "  ctr=ctr+1", 
      "  alphas[ctr]=1-alphaList[i];", 
      "  ctr=ctr+1", 
      "", 
      "               "
     ], 
     "language": "python", 
     "outputs": [], 
     "prompt_number": 4
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "print alphas", 
      "values=alphas"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "stream", 
       "stream": "stdout", 
       "text": [
        "[0.3, 0.7, 0.4, 0.6, 0.3, 0.7]"
       ]
      }
     ], 
     "prompt_number": 50
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "print values"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "stream", 
       "stream": "stdout", 
       "text": [
        "[0.3, 0.7, 0.4, 0.6, 0.3, 0.7]"
       ]
      }
     ], 
     "prompt_number": 51
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "import numpy as np", 
      "", 
      "x = np.array([[1, 2, 3], [4, 5, 6]], np.int32)", 
      "print np.shape(x)"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "stream", 
       "stream": "stdout", 
       "text": [
        "(2, 3)"
       ]
      }
     ], 
     "prompt_number": 2
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "x"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "pyout", 
       "prompt_number": 9, 
       "text": [
        "array([[1, 2, 3],", 
        "       [4, 5, 6]], dtype=int32)"
       ]
      }
     ], 
     "prompt_number": 9
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "x[:,1]"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "pyout", 
       "prompt_number": 10, 
       "text": [
        "array([2, 5], dtype=int32)"
       ]
      }
     ], 
     "prompt_number": 10
    }, 
    {
     "cell_type": "code", 
     "collapsed": true, 
     "input": [
      "x=np.array(range(27))"
     ], 
     "language": "python", 
     "outputs": [], 
     "prompt_number": 11
    }, 
    {
     "cell_type": "code", 
     "collapsed": true, 
     "input": [
      "x=np.array([[[ 0,  1,  2],", 
      "        [ 3,  4,  5],", 
      "        [ 6,  7,  8]],", 
      "       [[ 9, 10, 11],", 
      "        [12, 13, 14],", 
      "        [15, 16, 17]],", 
      "       [[18, 19, 20],", 
      "        [21, 22, 23],", 
      "        [24, 25, 26]]])"
     ], 
     "language": "python", 
     "outputs": [], 
     "prompt_number": 13
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "x"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "pyout", 
       "prompt_number": 14, 
       "text": [
        "array([[[ 0,  1,  2],", 
        "        [ 3,  4,  5],", 
        "        [ 6,  7,  8]],", 
        "", 
        "       [[ 9, 10, 11],", 
        "        [12, 13, 14],", 
        "        [15, 16, 17]],", 
        "", 
        "       [[18, 19, 20],", 
        "        [21, 22, 23],", 
        "        [24, 25, 26]]])"
       ]
      }
     ], 
     "prompt_number": 14
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "x[1,:,:]"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "pyout", 
       "prompt_number": 15, 
       "text": [
        "array([[ 9, 10, 11],", 
        "       [12, 13, 14],", 
        "       [15, 16, 17]])"
       ]
      }
     ], 
     "prompt_number": 15
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "#this is a 3d eqivalent of childGivenParentalGenotypeFactor", 
      "c_pm=np.arange(1000).reshape(10,10,10)"
     ], 
     "language": "python", 
     "outputs": [
      {
       "ename": "NameError", 
       "evalue": "name 'np' is not defined", 
       "output_type": "pyerr", 
       "traceback": [
        "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m\n\u001b[0;31mNameError\u001b[0m                                 Traceback (most recent call last)", 
        "\u001b[0;32m/Users/amit/software/pgmPy/PythonNotebooks/<ipython-input-1-28bdc4a032e3>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[1;32m      1\u001b[0m \u001b[0;31m#this is a 3d eqivalent of childGivenParentalGenotypeFactor\u001b[0m\n\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 2\u001b[0;31m \u001b[0mc_pm\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0marange\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m1000\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mreshape\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m10\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m10\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m10\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", 
        "\u001b[0;31mNameError\u001b[0m: name 'np' is not defined"
       ]
      }
     ], 
     "prompt_number": 1
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "from Factor import *", 
      "from PedigreeFactors import *", 
      "from PedigreeFactors import *", 
      "from GeneticNetworkFactory import *", 
      "import itertools", 
      "import numpy as np", 
      "alphaList=[.8,.6,.1]", 
      "allelefreq=[.1,.9]", 
      "chrom='12'", 
      "position=1000", 
      "g1=GeneticNetworkFactory('sixperson.ped',alphaList,allelefreq, chrom,position)", 
      "g1.constructNetwork()", 
      "factorList=g1.getFactorList()", 
      "for f in factorList:", 
      "    print f.getFactor()", 
      "    print \"==\""
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "stream", 
       "stream": "stdout", 
       "text": [
        "name: 1 genotype ", 
        "var: 1", 
        "card: 3", 
        "val: 0.01 0.18 0.81", 
        "==", 
        "name: 2 genotype |1,3", 
        "var: 2 1 3", 
        "card: 3 3 3", 
        "val: 1.0 0.0 0.0 0.5 0.5 0.0 0.0 1.0 0.0 0.5 0.5 0.0 0.25 0.5 0.25 0.0 0.5 0.5 0.0 1.0 0.0 0.0 0.5 0.5 0.0 0.0 1.0", 
        "==", 
        "name: 3 genotype ", 
        "var: 3", 
        "card: 3", 
        "val: 0.01 0.18 0.81", 
        "==", 
        "name: 4 genotype |1,3", 
        "var: 4 1 3", 
        "card: 3 3 3", 
        "val: 1.0 0.0 0.0 0.5 0.5 0.0 0.0 1.0 0.0 0.5 0.5 0.0 0.25 0.5 0.25 0.0 0.5 0.5 0.0 1.0 0.0 0.0 0.5 0.5 0.0 0.0 1.0", 
        "==", 
        "name: 5 genotype |2,6", 
        "var: 5 2 6", 
        "card: 3 3 3", 
        "val: 1.0 0.0 0.0 0.5 0.5 0.0 0.0 1.0 0.0 0.5 0.5 0.0 0.25 0.5 0.25 0.0 0.5 0.5 0.0 1.0 0.0 0.0 0.5 0.5 0.0 0.0 1.0", 
        "==", 
        "name: 6 genotype ", 
        "var: 6", 
        "card: 3", 
        "val: 0.01 0.18 0.81", 
        "==", 
        "name: 1 phenotype | 1 genotype", 
        "var: 7 1", 
        "card: 2 3", 
        "val: 0.8 0.2 0.6 0.4 0.1 0.9", 
        "==", 
        "name: 2 phenotype | 2 genotype", 
        "var: 8 2", 
        "card: 2 3", 
        "val: 0.8 0.2 0.6 0.4 0.1 0.9", 
        "==", 
        "name: 3 phenotype | 3 genotype", 
        "var: 9 3", 
        "card: 2 3", 
        "val: 0.8 0.2 0.6 0.4 0.1 0.9", 
        "==", 
        "name: 4 phenotype | 4 genotype", 
        "var: 10 4", 
        "card: 2 3", 
        "val: 0.8 0.2 0.6 0.4 0.1 0.9", 
        "==", 
        "name: 5 phenotype | 5 genotype", 
        "var: 11 5", 
        "card: 2 3", 
        "val: 0.8 0.2 0.6 0.4 0.1 0.9", 
        "==", 
        "name: 6 phenotype | 6 genotype", 
        "var: 12 6", 
        "card: 2 3", 
        "val: 0.8 0.2 0.6 0.4 0.1 0.9", 
        "=="
       ]
      }
     ], 
     "prompt_number": 10
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "#ok now start the decoupled factor testing", 
      "#prob(child haplotype|grand(paternal), grand(maternal)", 
      "import numpy as np", 
      "from PedigreeFactors import *", 
      "", 
      "numAlleles=2", 
      "index=0", 
      "values=np.zeros( np.prod([ numAlleles,numAlleles,numAlleles])).tolist()", 
      "for i in range(numAlleles):", 
      "    #iterate through alleles from", 
      "    #grand(paternal) haplotype", 
      "    for j in range(numAlleles):", 
      "        #iterate through alleles from", 
      "        #grand(maternal) haplotype", 
      "        for k in range(numAlleles):", 
      "            #iterate thru child alleles", 
      "            print i, j, k", 
      "            if j==k:#child has grandmotherhap", 
      "                if i==k:#grandfatherhap is the same", 
      "                    values[index]=1", 
      "                else:", 
      "                    values[index]=.5", 
      "            elif i==k:#child has grandfather hap", 
      "                values[index]=.5", 
      "            else:", 
      "                pass", 
      "            index+=1", 
      "print values", 
      "", 
      "                "
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "stream", 
       "stream": "stdout", 
       "text": [
        "0 0 0", 
        "0 0 1", 
        "0 1 0", 
        "0 1 1", 
        "1 0 0", 
        "1 0 1", 
        "1 1 0", 
        "1 1 1", 
        "[1, 0.0, 0.5, 0.5, 0.5, 0.5, 0.0, 1]"
       ]
      }
     ], 
     "prompt_number": 1
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "f1=ChildCopyGivenParentalsFactor(2,3,2,1)"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "stream", 
       "stream": "stdout", 
       "text": [
        "0 0 0", 
        "0 0 1", 
        "0 1 0", 
        "0 1 1", 
        "1 0 0", 
        "1 0 1", 
        "1 1 0", 
        "1 1 1", 
        "[1, 0.0, 0.5, 0.5, 0.5, 0.5, 0.0, 1]", 
        "name: child|hap1,hap2", 
        "var: 3 2 1", 
        "card: 2 2 2", 
        "val: 1.0 0.0 0.5 0.5 0.5 0.5 0.0 1.0"
       ]
      }
     ], 
     "prompt_number": 2
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "#phenotype|paterna, maternal haploytpes", 
      "#decoupled BN for Pr(pheno|geno)", 
      "", 
      "from Factor import *", 
      "from PGMcommon import *", 
      "from PedigreeFactors import *", 
      "numAlleles=2", 
      "f=phenotypeGivenHaplotypesFactor([.3,.7,.4],numAlleles,3,2,1)", 
      "print f"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "stream", 
       "stream": "stdout", 
       "text": [
        "name: phenotype| geneCopy1, geneCopy2", 
        "var: 1 3 2", 
        "card: 2 2 2", 
        "val: 0.3 0.7 0.7 0.3 0.7 0.3 0.4 0.6"
       ]
      }
     ], 
     "prompt_number": 1
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "foo=[1,2,3,4,5,6,8,9,10,11,12]", 
      "print len(foo)", 
      "print max(foo)", 
      "newmap=np.zeros( max(foo), dtype=int ).tolist()", 
      "print newmap, len(newmap)"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "stream", 
       "stream": "stdout", 
       "text": [
        "11", 
        "12", 
        "[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] 12"
       ]
      }
     ], 
     "prompt_number": 4
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "for i in range ( len( foo) ):", 
      "    print i", 
      "    newmap [ foo[i]-1 ] = i+1", 
      "newmap"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "stream", 
       "stream": "stdout", 
       "text": [
        "0", 
        "1", 
        "2", 
        "3", 
        "4", 
        "5", 
        "6", 
        "7", 
        "8", 
        "9", 
        "10"
       ]
      }, 
      {
       "output_type": "pyout", 
       "prompt_number": 5, 
       "text": [
        "[1, 2, 3, 4, 5, 6, 0, 7, 8, 9, 10, 11]"
       ]
      }
     ], 
     "prompt_number": 5
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "import sys", 
      "import numpy as np", 
      "from Factor import *", 
      "from PGMcommon import *", 
      "from PedigreeFactors import *", 
      "from FactorOperations import *", 
      "from GeneticNetworkFactory import *", 
      "from CliqueTree import *", 
      "import networkx as nx", 
      "import matplotlib.pyplot as plt", 
      "from CliqueTreeOperations import *", 
      "#to create a clique tree, we start with a list of factors", 
      "#and potentially some observed evidence", 
      "alphaList=[.8,.6,.1]", 
      "allelefreq=[.1,.9]", 
      "chrom='12'", 
      "position=1000", 
      "g1=GeneticNetworkFactory('sixperson.ped',alphaList,allelefreq, chrom,position)", 
      "g1.constructNetwork()", 
      "factorList=g1.getFactorList()", 
      "#for f in factorList:", 
      "#    print f.getFactor()", 
      "#    print ", 
      "", 
      "\"\"\" create cTree, prune it, then compute initial potentials \"\"\"", 
      "cTree = createCliqueTree(factorList)", 
      "cTree=PruneTree( cTree )", 
      "P=CliqueTreeInitialPotential ( cTree )", 
      "P.toString()", 
      "\"\"\" we need to come up wih a proper message passing order. A clique is ready to pass", 
      "messages upward once its recieved all downstream messages from its neighbor (and vice versa)", 
      "its ready to transmit downstream once it recieves all its upstream messages", 
      "", 
      "the ith clique C_i is ready to transmit to its neighbor C_j when C_i recieves all its ", 
      "messages from neigbors except C_j. In cTree message passing, each message is passed ", 
      "once.  To get the process started we start with our initial potential cTree, P", 
      "and an empty matrix of factors, representing messages passed between the nodes on the clique", 
      "tree \"\"\"", 
      "", 
      "#totalNodes=P.getNodeCount()", 
      "#messages=np.array( [ Factor( [], [], [], '0' ) ] ) ", 
      "#messages= np.tile(messages, (totalNodes, totalNodes))", 
      "#(a,b)=getNextClique(P,messages)", 
      "#print 'a: ', a, ' b: ', b"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "stream", 
       "stream": "stdout", 
       "text": [
        "nodes:  [<Factor.Factor object at 0x104a8aa50>, <Factor.Factor object at 0x104a8a250>, <Factor.Factor object at 0x104a8a890>, <Factor.Factor object at 0x104a8a4d0>, <Factor.Factor object at 0x104a8a610>, <Factor.Factor object at 0x104a8a8d0>, <Factor.Factor object at 0x104a8a410>, <Factor.Factor object at 0x104a8a190>, <Factor.Factor object at 0x104a8a550>]", 
        "card:  [3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2]", 
        "factorList:  12", 
        "factorInds: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]", 
        "edges:", 
        "[[ 0.  0.  0.  0.  0.  0.  0.  1.  0.]", 
        " [ 0.  0.  0.  0.  0.  0.  0.  0.  1.]", 
        " [ 0.  0.  0.  0.  0.  0.  0.  1.  0.]", 
        " [ 0.  0.  0.  0.  0.  0.  1.  0.  0.]", 
        " [ 0.  0.  0.  0.  0.  0.  0.  0.  1.]", 
        " [ 0.  0.  0.  0.  0.  0.  0.  0.  1.]", 
        " [ 0.  0.  0.  1.  0.  0.  0.  1.  0.]", 
        " [ 1.  0.  1.  0.  0.  0.  1.  0.  1.]", 
        " [ 0.  1.  0.  0.  1.  1.  0.  1.  0.]]"
       ]
      }, 
      {
       "output_type": "stream", 
       "stream": "stderr", 
       "text": [
        "A factor is empty!", 
        "A factor is empty!", 
        "A factor is empty!", 
        "A factor is empty!", 
        "A factor is empty!", 
        "A factor is empty!", 
        "A factor is empty!", 
        "A factor is empty!", 
        "A factor is empty!", 
        "A factor is empty!", 
        "A factor is empty!", 
        "A factor is empty!", 
        "FactorMarginalization:Error, resultant factor has empty scope..."
       ]
      }, 
      {
       "output_type": "pyout", 
       "prompt_number": 1, 
       "text": [
        "' we need to come up wih a proper message passing order. A clique is ready to pass\\nmessages upward once its recieved all downstream messages from its neighbor (and vice versa)\\nits ready to transmit downstream once it recieves all its upstream messages\\n\\nthe ith clique C_i is ready to transmit to its neighbor C_j when C_i recieves all its \\nmessages from neigbors except C_j. In cTree message passing, each message is passed \\nonce.  To get the process started we start with our initial potential cTree, P\\nand an empty matrix of factors, representing messages passed between the nodes on the clique\\ntree '"
       ]
      }
     ], 
     "prompt_number": 1
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "run 'testGetNextC.py'"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "stream", 
       "stream": "stdout", 
       "text": [
        "", 
        "", 
        "", 
        "", 
        "", 
        "a:  8  b: 1"
       ]
      }
     ], 
     "prompt_number": 1
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "run 'testCliqueTreeCalibrate.py'"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "stream", 
       "stream": "stdout", 
       "text": [
        "[[ 1  2  3  4  5  6  7  8  9]", 
        " [10 11 12 13 14 15 16 17 18]", 
        " [19 20 21 22 23 24 25 26 27]", 
        " [28 29 30 31 32 33 34 35 36]", 
        " [37 38 39 40 41 42 43 44 45]", 
        " [46 47 48 49 50 51 52 53 54]", 
        " [55 56 57 58 59 60 61 62 63]", 
        " [64 65 66 67 68 69 70 71 72]", 
        " [73 74 75 76 77 78 79 80 81]]", 
        "i:  6 j:  7", 
        "[34]", 
        "name: None", 
        "var: 4", 
        "card: 3", 
        "val: 0.333333333333 0.333333333333 0.333333333333", 
        "total number of Nbs factors:  1", 
        "[4]", 
        "[ 3.]", 
        "[[ 0.33333333  0.33333333  0.33333333]]", 
        "", 
        "i:  7 j:  8", 
        "[ 8 26 62]", 
        "name: None", 
        "var: 1", 
        "card: 3", 
        "val: 0.01 0.18 0.81", 
        "name: None", 
        "var: 3", 
        "card: 3", 
        "val: 0.01 0.18 0.81", 
        "name: None", 
        "var: 1 3", 
        "card: 3.0 3.0", 
        "val: 0.111111111111 0.111111111111 0.111111111111 0.111111111111 0.111111111111 0.111111111111 0.111111111111 0.111111111111 0.111111111111", 
        "total number of Nbs factors:  3", 
        "[1 3]", 
        "[ 3.  3.]", 
        "[[ 0.00001111  0.0002      0.0009    ]", 
        " [ 0.0002      0.0036      0.0162    ]", 
        " [ 0.0009      0.0162      0.0729    ]]", 
        "", 
        "i:  8 j:  1", 
        "[45 54 72]", 
        "name: None", 
        "var: 5", 
        "card: 3", 
        "val: 0.333333333333 0.333333333333 0.333333333333", 
        "name: None", 
        "var: 6", 
        "card: 3", 
        "val: 0.01 0.18 0.81", 
        "name: None", 
        "var: 2", 
        "card: 3.0", 
        "val: 0.01 0.18 0.81", 
        "total number of Nbs factors:  3", 
        "[2 5 6]", 
        "[ 3.  3.  3.]", 
        "[[ 0.00003333  0.0006      0.0027    ]", 
        " [ 0.00003333  0.0006      0.0027    ]", 
        " [ 0.00003333  0.0006      0.0027    ]", 
        " [ 0.0006      0.0108      0.0486    ]", 
        " [ 0.0006      0.0108      0.0486    ]", 
        " [ 0.0006      0.0108      0.0486    ]", 
        " [ 0.0027      0.0486      0.2187    ]", 
        " [ 0.0027      0.0486      0.2187    ]", 
        " [ 0.0027      0.0486      0.2187    ]]", 
        "", 
        "i:  8 j:  4", 
        "[18 54 72]", 
        "name: None", 
        "var: 2", 
        "card: 3", 
        "val: 0.333333333333 0.333333333333 0.333333333333", 
        "name: None", 
        "var: 6", 
        "card: 3", 
        "val: 0.01 0.18 0.81", 
        "name: None", 
        "var: 2", 
        "card: 3.0", 
        "val: 0.01 0.18 0.81", 
        "total number of Nbs factors:  3", 
        "[2 6]", 
        "[ 3.  3.]", 
        "[[ 0.00003333  0.0006      0.0027    ]", 
        " [ 0.0006      0.0108      0.0486    ]", 
        " [ 0.0027      0.0486      0.2187    ]]", 
        "", 
        "i:  8 j:  5", 
        "[18 45 72]", 
        "name: None", 
        "var: 2", 
        "card: 3", 
        "val: 0.333333333333 0.333333333333 0.333333333333", 
        "name: None", 
        "var: 5", 
        "card: 3", 
        "val: 0.333333333333 0.333333333333 0.333333333333", 
        "name: None", 
        "var: 2", 
        "card: 3.0", 
        "val: 0.01 0.18 0.81", 
        "total number of Nbs factors:  3", 
        "[2 5]", 
        "[ 3.  3.]", 
        "[[ 0.00111111  0.02        0.09      ]", 
        " [ 0.00111111  0.02        0.09      ]", 
        " [ 0.00111111  0.02        0.09      ]]", 
        "", 
        "i:  8 j:  7", 
        "[18 45 54]", 
        "name: None", 
        "var: 2", 
        "card: 3", 
        "val: 0.333333333333 0.333333333333 0.333333333333", 
        "name: None", 
        "var: 5", 
        "card: 3", 
        "val: 0.333333333333 0.333333333333 0.333333333333", 
        "name: None", 
        "var: 6", 
        "card: 3", 
        "val: 0.01 0.18 0.81", 
        "total number of Nbs factors:  3", 
        "[2 5 6]", 
        "[ 3.  3.  3.]", 
        "[[ 0.00111111  0.00111111  0.00111111]", 
        " [ 0.00111111  0.00111111  0.00111111]", 
        " [ 0.00111111  0.00111111  0.00111111]", 
        " [ 0.02        0.02        0.02      ]", 
        " [ 0.02        0.02        0.02      ]", 
        " [ 0.02        0.02        0.02      ]", 
        " [ 0.09        0.09        0.09      ]", 
        " [ 0.09        0.09        0.09      ]", 
        " [ 0.09        0.09        0.09      ]]", 
        "", 
        "i:  7 j:  0", 
        "[26 62 80]", 
        "name: None", 
        "var: 3", 
        "card: 3", 
        "val: 0.01 0.18 0.81", 
        "name: None", 
        "var: 1 3", 
        "card: 3.0 3.0", 
        "val: 0.111111111111 0.111111111111 0.111111111111 0.111111111111 0.111111111111 0.111111111111 0.111111111111 0.111111111111 0.111111111111", 
        "name: None", 
        "var: 2", 
        "card: 3.0", 
        "val: 0.333333333333 0.333333333333 0.333333333333", 
        "total number of Nbs factors:  3", 
        "[1 2 3]", 
        "[ 3.  3.  3.]", 
        "[[ 0.00037037  0.00037037  0.00037037]", 
        " [ 0.00037037  0.00037037  0.00037037]", 
        " [ 0.00037037  0.00037037  0.00037037]", 
        " [ 0.00666667  0.00666667  0.00666667]", 
        " [ 0.00666667  0.00666667  0.00666667]", 
        " [ 0.00666667  0.00666667  0.00666667]", 
        " [ 0.03        0.03        0.03      ]", 
        " [ 0.03        0.03        0.03      ]", 
        " [ 0.03        0.03        0.03      ]]", 
        "", 
        "i:  7 j:  2", 
        "[ 8 62 80]", 
        "name: None", 
        "var: 1", 
        "card: 3", 
        "val: 0.01 0.18 0.81", 
        "name: None", 
        "var: 1 3", 
        "card: 3.0 3.0", 
        "val: 0.111111111111 0.111111111111 0.111111111111 0.111111111111 0.111111111111 0.111111111111 0.111111111111 0.111111111111 0.111111111111", 
        "name: None", 
        "var: 2", 
        "card: 3.0", 
        "val: 0.333333333333 0.333333333333 0.333333333333", 
        "total number of Nbs factors:  3", 
        "[1 2 3]"
       ]
      }, 
      {
       "output_type": "stream", 
       "stream": "stdout", 
       "text": [
        "", 
        "[ 3.  3.  3.]", 
        "[[ 0.00037037  0.00666667  0.03      ]", 
        " [ 0.00037037  0.00666667  0.03      ]", 
        " [ 0.00037037  0.00666667  0.03      ]", 
        " [ 0.00037037  0.00666667  0.03      ]", 
        " [ 0.00037037  0.00666667  0.03      ]", 
        " [ 0.00037037  0.00666667  0.03      ]", 
        " [ 0.00037037  0.00666667  0.03      ]", 
        " [ 0.00037037  0.00666667  0.03      ]", 
        " [ 0.00037037  0.00666667  0.03      ]]", 
        "", 
        "i:  7 j:  6", 
        "[ 8 26 80]", 
        "name: None", 
        "var: 1", 
        "card: 3", 
        "val: 0.01 0.18 0.81", 
        "name: None", 
        "var: 3", 
        "card: 3", 
        "val: 0.01 0.18 0.81", 
        "name: None", 
        "var: 2", 
        "card: 3.0", 
        "val: 0.333333333333 0.333333333333 0.333333333333", 
        "total number of Nbs factors:  3", 
        "[1 2 3]", 
        "[ 3.  3.  3.]", 
        "[[ 0.00003333  0.0006      0.0027    ]", 
        " [ 0.00003333  0.0006      0.0027    ]", 
        " [ 0.00003333  0.0006      0.0027    ]", 
        " [ 0.0006      0.0108      0.0486    ]", 
        " [ 0.0006      0.0108      0.0486    ]", 
        " [ 0.0006      0.0108      0.0486    ]", 
        " [ 0.0027      0.0486      0.2187    ]", 
        " [ 0.0027      0.0486      0.2187    ]", 
        " [ 0.0027      0.0486      0.2187    ]]", 
        "", 
        "i:  6 j:  3", 
        "[70]", 
        "name: None", 
        "var: 1 3", 
        "card: 3.0 3.0", 
        "val: 0.0001 0.0018 0.0081 0.0018 0.0324 0.1458 0.0081 0.1458 0.6561", 
        "total number of Nbs factors:  1", 
        "[1 3]", 
        "[ 3.  3.]", 
        "[[ 0.0001  0.0018  0.0081]", 
        " [ 0.0018  0.0324  0.1458]", 
        " [ 0.0081  0.1458  0.6561]]"
       ]
      }
     ], 
     "prompt_number": 1
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "from Factor import *", 
      "from PGMcommon import *", 
      "from CliqueTree import *", 
      "from CliqueTreeOperations import *", 
      "from FactorOperations import *", 
      "import scipy.io as sio", 
      "import numpy as np", 
      "", 
      "matfile='/Users/amit/BC_Classes/PGM/Prog4/PA4Sample.mat'", 
      "mat_contents=sio.loadmat(matfile)", 
      "mat_struct=mat_contents['ExactMarginal']", 
      "val=mat_struct[0,0]", 
      "print len ( val['INPUT'][0] )"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "stream", 
       "stream": "stdout", 
       "text": [
        "12"
       ]
      }
     ], 
     "prompt_number": 4
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "run testCliqueTreeOperations.py"
     ], 
     "language": "python", 
     "outputs": [
      {
       "ename": "IndexError", 
       "evalue": "list index out of range", 
       "output_type": "pyerr", 
       "traceback": [
        "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m\n\u001b[0;31mIndexError\u001b[0m                                Traceback (most recent call last)", 
        "\u001b[0;32m/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/ipython-0.12.1-py2.7.egg/IPython/utils/py3compat.pyc\u001b[0m in \u001b[0;36mexecfile\u001b[0;34m(fname, *where)\u001b[0m\n\u001b[1;32m    173\u001b[0m             \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    174\u001b[0m                 \u001b[0mfilename\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mfname\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 175\u001b[0;31m             \u001b[0m__builtin__\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mexecfile\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mfilename\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m*\u001b[0m\u001b[0mwhere\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", 
        "\u001b[0;32m/Users/amit/software/pgmPy/PythonNotebooks/testCliqueTreeOperations.py\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[1;32m     25\u001b[0m \u001b[0;31m#print \"+++++++++\"\u001b[0m\n\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m     26\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 27\u001b[0;31m \u001b[0mcTree\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mcreateCliqueTree\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mfactorList\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m     28\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m     29\u001b[0m \u001b[0;31m#cTree.toString()\u001b[0m\n\u001b[0;34m\u001b[0m\u001b[0m\n", 
        "\u001b[0;32m/Users/amit/software/pgmPy/CliqueTreeOperations.py\u001b[0m in \u001b[0;36mcreateCliqueTree\u001b[0;34m(factorList)\u001b[0m\n\u001b[1;32m     50\u001b[0m         \u001b[0mcliquesConsidered\u001b[0m\u001b[0;34m+=\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m     51\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 52\u001b[0;31m         \u001b[0medges\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mfactorList\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mC\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0meliminateVar\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mbestClique\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0medges\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mfactorList\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m     53\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m     54\u001b[0m     \u001b[0;32mreturn\u001b[0m \u001b[0mC\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", 
        "\u001b[0;32m/Users/amit/software/pgmPy/CliqueTree.pyc\u001b[0m in \u001b[0;36meliminateVar\u001b[0;34m(self, Z, E, factorList)\u001b[0m\n\u001b[1;32m    178\u001b[0m             \u001b[0;31m#there was the off by onoe erorr - the values in factorInds\u001b[0m\n\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    179\u001b[0m             \u001b[0;31m#were one-based, need to subtract 1\u001b[0m\n\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 180\u001b[0;31m             \u001b[0;32mif\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mfactorInds\u001b[0m \u001b[0;34m[\u001b[0m \u001b[0mi\u001b[0m \u001b[0;34m]\u001b[0m \u001b[0;34m-\u001b[0m\u001b[0;36m1\u001b[0m  \u001b[0;32min\u001b[0m \u001b[0museFactors\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m    181\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    182\u001b[0m                 \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0medges\u001b[0m\u001b[0;34m[\u001b[0m \u001b[0mi\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mnewC\u001b[0m\u001b[0;34m-\u001b[0m\u001b[0;36m1\u001b[0m \u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;36m1\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", 
        "\u001b[0;31mIndexError\u001b[0m: list index out of range"
       ]
      }, 
      {
       "output_type": "stream", 
       "stream": "stderr", 
       "text": [
        "A factor is empty!"
       ]
      }
     ], 
     "prompt_number": 2
    }, 
    {
     "cell_type": "code", 
     "collapsed": true, 
     "input": [
      "import numpy as np", 
      "from Factor import *", 
      "from FactorOperations import *", 
      "from PGMcommon import *", 
      "", 
      "psi=Factor([4,2], card=[2,3], val=[.1,.9,.4,.6,.99,.01], name='4,2')"
     ], 
     "language": "python", 
     "outputs": [], 
     "prompt_number": 3
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "foo=ObserveEvidence([psi], np.array( [[2,3]] ) )[0]", 
      "print foo"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "stream", 
       "stream": "stdout", 
       "text": [
        "name: 4,2", 
        "var: 4 2", 
        "card: 2 3", 
        "val: 0.0 0.0 0.0 0.0 0.99 0.01"
       ]
      }
     ], 
     "prompt_number": 17
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "print IndexToAssignment(np.arange(6),foo.getCard() )"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "stream", 
       "stream": "stdout", 
       "text": [
        "[[ 1.  1.]", 
        " [ 2.  1.]", 
        " [ 1.  2.]", 
        " [ 2.  2.]", 
        " [ 1.  3.]", 
        " [ 2.  3.]]"
       ]
      }
     ], 
     "prompt_number": 16
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "print FactorMaxMarginalization(foo, [2])"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "stream", 
       "stream": "stdout", 
       "text": [
        "name: None", 
        "var: 2", 
        "card: 3", 
        "val: 0.0 0.0 0.99"
       ]
      }
     ], 
     "prompt_number": 14
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "psi=Factor( [1,2], card=[2,3], val=[0.1296,0.048,0.1596, 0.0665, 0.1197, 0.1862] )", 
      "foo=ObserveEvidence([psi], np.array( [[2,3]] ) )[0]", 
      "print foo"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "stream", 
       "stream": "stdout", 
       "text": [
        "name: None", 
        "var: 1 2", 
        "card: 2 3", 
        "val: 0.0 0.0 0.0 0.0 0.1197 0.1862"
       ]
      }
     ], 
     "prompt_number": 19
    }, 
    {
     "cell_type": "code", 
     "collapsed": true, 
     "input": [
      "value=[0.1995, 0.03325, 0.266, 0.16625, 0.1995, 0.4655, 0.216, 0.12, 0.0192, 0.072, 0.0048, 0.048]"
     ], 
     "language": "python", 
     "outputs": [], 
     "prompt_number": 23
    }, 
    {
     "cell_type": "code", 
     "collapsed": true, 
     "input": [
      "psi=Factor([1,2,5], card=[2,3,2], val=value)"
     ], 
     "language": "python", 
     "outputs": [], 
     "prompt_number": 25
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "foo=ObserveEvidence( [psi], np.array( [ [1,1], [2,3]]) )[0]", 
      "print FactorMarginalization( foo, [1,2])"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "stream", 
       "stream": "stdout", 
       "text": [
        "name: None", 
        "var: 5", 
        "card: 2", 
        "val: 0.1995 0.0048"
       ]
      }
     ], 
     "prompt_number": 32
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "IndexToAssignment(np.arange(2), np.array([2]) )"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "pyout", 
       "prompt_number": 33, 
       "text": [
        "array([[ 1.],", 
        "       [ 2.]])"
       ]
      }
     ], 
     "prompt_number": 33
    }, 
    {
     "cell_type": "code", 
     "collapsed": true, 
     "input": [
      "import numpy as np", 
      "x=[.5,.3,.9,1]"
     ], 
     "language": "python", 
     "outputs": [], 
     "prompt_number": 7
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "x.index( max(x))"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "pyout", 
       "prompt_number": 9, 
       "text": [
        "3"
       ]
      }
     ], 
     "prompt_number": 9
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "import itertools", 
      "x=[1,2,3]", 
      "y=[0,1,2]", 
      "", 
      "for (foo,bar) in itertools.izip( x,y):", 
      "    print foo, bar"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "stream", 
       "stream": "stdout", 
       "text": [
        "1 0", 
        "2 1", 
        "3 2"
       ]
      }
     ], 
     "prompt_number": 10
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "import numpy as np", 
      "np.arange( np.prod( [1,2,3]) )"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "pyout", 
       "prompt_number": 3, 
       "text": [
        "array([0, 1, 2, 3, 4, 5])"
       ]
      }
     ], 
     "prompt_number": 3
    }, 
    {
     "cell_type": "code", 
     "collapsed": true, 
     "input": [
      "import numpy as np", 
      "from Factor import *", 
      "from FactorOperations import *", 
      "from PGMcommon import *", 
      "", 
      "psi=Factor([4,2], card=[2,3], val=[.1,.9,.4,.6,.99,.01], name='4,2')"
     ], 
     "language": "python", 
     "outputs": [], 
     "prompt_number": 1
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "psilog=LogFactor(psi)", 
      "print psi", 
      "print psilog"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "stream", 
       "stream": "stdout", 
       "text": [
        "name: 4,2", 
        "var: 4 2", 
        "card: 2 3", 
        "val: 0.1 0.9 0.4 0.6 0.99 0.01", 
        "name: 4,2", 
        "var: 4 2", 
        "card: 2 3", 
        "val: -2.30258509299 -0.105360515658 -0.916290731874 -0.510825623766 -0.0100503358535 -4.60517018599"
       ]
      }
     ], 
     "prompt_number": 2
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "np.log(.1)"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "pyout", 
       "prompt_number": 3, 
       "text": [
        "-2.3025850929940455"
       ]
      }
     ], 
     "prompt_number": 3
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "run 'testCliqueTreeMaxSumCalibrate.py'"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "stream", 
       "stream": "stdout", 
       "text": [
        "name: None", 
        "var: 1 2", 
        "card: 26.0 26.0", 
        "val: -37.7817953688 -46.6039065725 -31.5675449098 -36.4108129692 -27.5577399601 -34.0014928498 -30.3645619789 -43.2957576608 -32.0735742642 -47.4091350401 -38.6287844874 -29.2621497127 -36.8457851186 -36.3992186317 -33.3418215415 -34.4348707512 -44.1966608809 -26.9995973931 -35.7623182251 -24.1894679215 -34.2324056731 -34.7688446581 -54.1093685558 -36.8035092391 -32.1640949085 -32.2189541726 -47.9374377741 -62.1039623302 -51.6919756673 -54.4309815299 -44.0300593536 -53.0263185708 -50.8242747833 -62.8312960669 -47.6669456303 -inf -55.1631766097 -48.0196407901 -51.955993359 -54.6213238791 -47.6417414637 -53.8357141478 -inf -44.5491814286 -52.6158148458 -42.9441538459 -48.7469658198 -inf -72.0254133708 -56.3051743286 -46.5762807024 -50.2863008963 -39.811612026 -56.4623889095 -39.7274821117 -46.6102553959 -34.717938557 -45.6873539124 -44.4943102379 -56.4822105571 -38.181906017 -56.758932999 -51.3297693722 -40.3392686743 -49.290426239 -43.095082609 -39.5765872691 -48.136824394 -inf -35.074319542 -43.3535118618 -33.8981913748 -40.8138884794 -47.5452387915 -65.9102241798 -43.2849000558 -39.524196178 -44.5959948858 -42.9799905613 -60.8501823987 -46.1518003118 -47.3792189483 -36.9655259393 -50.4044888061 -44.8012476224 -58.4822453975 -41.6771745085 -inf -51.7859865179 -39.9839208542 -52.7863465649 -45.2659225968 -42.8706996555 -50.6203670607 -inf -38.4589928405 -48.2370080903 -40.5477929955 -44.7868267111 -51.7391255213 -67.2643829088 -inf -43.322238639 -47.4035872837 -35.0507644705 -44.7982656192 -29.6457536914 -34.0327524516 -26.6633113049 -31.4377224081 -28.3191198827 -41.1823990228 -30.8513736432 -44.130601693 -34.7518029431 -28.1418603336 -34.8437642538 -34.5279416968 -33.2793795455 -33.4581526584 -inf -25.3010478574 -33.1879346403 -22.1046750302 -33.1901808126 -31.1320162458 -52.045321145 -35.2179627228 -29.7087539444 -30.4395512448 -46.3777833618 -65.9716583983 -47.8975441002 -51.4658198642 -40.2983358656 -43.2242638762 -46.8685750123 -60.9522998091 -43.9138602379 -inf -52.0032464833 -43.1437505045 -52.7316727716 -49.5252443046 -45.1180845288 -51.7193653623 -inf -41.9091719726 -49.4666855342 -39.6734093293 -47.3972622301 -inf -69.7434059671 -52.137015916 -46.4384502289 -49.2584560053 -38.4101308872 -59.0816469262 -42.0147951654 -42.8374840133 -34.2693097819 -42.5269836216 -36.8041394979 -56.83487707 -36.780066603 -inf -46.8249517684 -39.2632446801 -49.0997578832 -40.2755656563 -38.749924175 -45.560967374 -inf -33.7590499864 -45.5711234727 -33.3746872043 -39.4309215754 -inf -65.7621153724 -48.7127403866 -39.8849110111 -41.5034471473 -54.1145323592 -70.4237052258 -49.1368906215 -58.2653471075 -48.4333703985 -59.589353634 -47.2844591931 -67.5563588554 -55.6762541216 -inf -58.0475190727 -53.27399208 -61.2780641454 -57.9136436326 -52.7644571939 -54.7485311917 -inf -49.6146066507 -53.8459639917 -41.9232968577 -56.9335706479 -inf -73.7368778368 -57.7522135727 -52.1737191792 -53.5492347035 -66.7091865655 -80.8742336217 -66.0618101251 -69.9572511763 -63.4379017039 -66.6137469426 -65.1296960895 -78.1449135102 -71.8438133411 -81.5510898649 -71.6092619766 -63.5402138355 -71.3196823155 -70.8622157193 -66.7818016567 -70.1463279311 -74.3937144984 -61.5814068935 -68.9759871196 -57.550027265 -68.6878203494 -68.1377119657 -88.9165370602 -71.5334276385 -65.3459449933 -66.7592567835 -56.469084656 -69.3213842872 -62.5054322554 -60.4717692384 -53.5284908843 -inf -58.7684129684 -75.1972824322 -58.2487512983 -inf -64.8901056341 -58.8567515157 -66.5458725187 -61.5542211377 -56.6679659748 -61.8890516631 -inf -54.7947677311 -64.6013582453 -52.8897720718 -60.1238118975 -inf -inf -inf -inf -inf -48.1293264123 -68.2801477369 -46.5613785164 -57.2001992266 -44.8860803662 -52.4351608729 -50.1530743502 -65.2756921737 -48.6844975803 -inf -55.8158132274 -47.2346836591 -59.3968709487 -52.1397192273 -48.0462677065 -55.1077748728 -inf -43.1097511983 -51.6142618582 -45.2299448762 -52.892893235 -57.9819251904 -72.4393419292 -inf -50.0336041136 -51.0073295974 -55.6297796487 -69.3283260587 -56.6109946055 -61.88272366 -51.8355706055 -58.1062444451 -55.7850140861 -71.1824625151 -55.2622508916 -inf -62.893766531 -52.6787379086 -64.8008478555 -62.3860267299 -55.4485523491 -59.1203628786 -inf -52.8632756678 -60.9428561719 -49.624175935 -57.4036191329 -63.0266498202 -79.9287691217 -65.6505930313 -56.0776567136 -59.1239756209 -40.6591376281 -56.7654598922 -44.3622772799 -45.2752269932 -35.6869077031 -44.3865310323 -41.1067090186 -55.0230950905 -39.8957293228 -59.8504995485 -48.8369001861 -39.7386918578 -44.783811395 -45.7693495756 -38.4815460364 -44.5791185911 -inf -35.7154904151 -44.2742781053 -33.5539272281 -41.7814745565 -50.008196673 -64.3598065594 -47.7039204743 -38.6455464256 -44.1322133642 -36.1158898201 -56.5087386102 -42.7740913297 -44.1272369506 -31.4233216769 -43.8237870591 -35.8427373545 -51.2662364512 -35.0894949794 -57.3521019008 -44.5729039126 -39.1029377722 -45.856691885 -42.5437794191 -35.2160955274 -46.6097297719 -inf -33.0952683052 -43.776468347 -32.1470139322 -38.0683529582 -46.0057216266 -58.7156653309 -46.235142232 -36.5546011291 -41.8749778077 -31.5460199215 -39.7524578162 -25.6410831438 -31.6260421547 -23.9852568716 -27.0304491882 -25.5612347536 -38.1616621115 -25.1067543664 -39.1214448581 -33.694096499 -24.252373019 -31.5954468125 -31.3682502144 -26.7882949972 -28.5299301929 -inf -21.1255778634 -29.569973964 -18.4387081421 -31.1088224603 -29.6385310746 -47.3101028409 -32.9539707996 -25.4958806472 -27.5195884364 -37.9885017538 -55.301486057 -43.9417445329 -45.2164185458 -33.1722637339 -inf -40.6972017521 -55.5349824579 -37.6642521419 -inf -45.8299810581 -36.722944436 -40.6599679639 -45.1717576705 -36.9442259841 -39.5837339376 -inf -32.924915082 -40.6303119101 -32.7436751318 -38.9602992186 -inf -63.0131255361 -39.8798950884 -36.7252522462 -41.9440187066 -63.0711474193 -inf -59.5849701576 -66.5750034512 -56.6634843079 -inf -65.2955743904 -76.3491654352 -61.7219115409 -inf -inf -inf -inf -66.9465671861 -64.7183441097 -inf -70.0099965715 -60.7753853895 -66.771810821 -60.3332242265 -66.4327197451 -inf -inf -68.5916718877 -inf -63.8568139966 -40.2427855107 -56.1838437656 -41.514016236 -45.2240036564 -35.2228100598 -43.7244115256 -39.570526089 -53.7281755029 -40.6886630026 -61.4182835618 -48.8037329174 -41.8799888167 -51.8649152125 -49.2320772857 -39.3832141872 -44.416712422 -inf -37.6484422769 -47.345110192 -33.3841400472 -41.6950192697 -47.6841603646 -65.1892934151 -inf -41.9645175035 -46.7296167987 -37.477098435 -52.3872742035 -39.5022054902 -41.9028793769 -32.2039093832 -40.7604291173 -36.5891686574 -52.0489062764 -36.8434797211 -57.3039286626 -42.5622630013 -35.891009974 -43.3566117708 -41.5083814218 -37.3676990383 -42.0517965005 -49.6847352305 -32.5326643879 -40.1610886771 -29.4067884374 -38.5920817536 -45.7124258976 -60.1023000858 -47.1032597218 -34.8759845021 -43.1260875323 -41.4589852728 -57.2058038268 -41.2143311923 -50.0119392574 -37.8054599848 -42.468944076 -42.2285587552 -54.3768395116 -41.1625509532 -inf -51.7194611374 -41.0386492741 -52.4515571678 -45.0445924252 -42.3333700992 -46.068018262 -inf -37.4418931945 -43.8659278942 -35.2860206135 -43.0951227721 -inf -65.8997558839 -45.969311506 -42.3701042762 -47.9248485731 -36.1712183868 -49.218809455 -34.4213447208 -38.4631919865 -33.3736868881 -36.1786306955 -33.3899317265 -48.8423961682 -37.4993541533 -48.0852326906 -42.9802207984 -33.0550463993 -41.0178884043 -39.9923262037 -33.1642461301 -38.630095157 -37.5107846815 -31.2144638988 -37.7887945601 -27.2920916647 -42.5253361099 -41.9972664564 -61.8663292375 -41.2140172269 -37.7645479019 -36.8399636241 -45.5456038475 -61.9061447644 -inf -50.295947563 -40.5064836707 -inf -50.0656900271 -63.0541414203 -44.0333884574 -64.7018907506 -55.7537467109 -44.0126365663 -55.8150013197 -49.8032958777 -44.7231691516 -inf -inf -41.5674932305 -53.0772564002 -44.0737204292 -50.6687528938 -52.7195216843 -inf -54.2780782606 -48.0272708154 -50.0132240008 -71.27361717 -87.8958402277 -77.1569252151 -76.0883430985 -65.786097283 -76.0498877311 -72.621398254 -84.8010584723 -73.3707418833 -89.337040517 -77.7109237177 -70.4898542239 -80.3988578064 -76.6439690842 -68.9784433187 -77.0260524541 -inf -67.7885137476 -75.3491964456 -63.8244462078 -76.090981655 -inf -inf -76.5429843 -69.9165001299 -72.9619748174 -43.5305223452 -inf -inf -inf -38.5848385229 -inf -47.1356726492 -inf -41.6545659261 -inf -inf -48.6103055835 -inf -50.8705613692 -44.2202663285 -inf -inf -42.688243058 -inf -inf -47.3448312175 -inf -inf -48.3948882415 -45.9214289264 -inf -38.7268228838 -54.5001169472 -39.3994152239 -43.6713657548 -35.1140897579 -41.1866434718 -38.0773188683 -53.1382591703 -44.6936398711 -inf -44.9078795671 -35.6250316429 -45.7563744487 -42.9094590592 -40.158957591 -44.5149471071 -inf -34.2942535384 -44.244658792 -30.0472785314 -41.7225761362 -42.9359478212 -62.1656738541 -45.6435182886 -44.8303552958 -40.3455089418 -45.525540915 -64.552169799 -48.3326158492 -52.7302839296 -41.9083708731 -48.850283756 -47.891433442 -62.8162255266 -43.5941694322 -inf -54.4549588665 -45.3099430169 -inf -50.3812417028 -46.125564738 -54.2701686556 -inf -43.9643082021 -51.8719946018 -38.0127586616 -48.1729126902 -52.462187732 -72.3312505259 -inf -44.836640053 -43.6455319308", 
        "==", 
        "name: None", 
        "var: 2 3", 
        "card: 26.0 26.0", 
        "val: -40.8860056492 -51.1498184814 -38.4272358481 -45.0631644907 -33.3933953204 -49.5815387256 -39.9452914979 -46.6168353458 -68.862593469 -58.7484852803 -52.811798722 -59.0666252596 -46.6429884647 -39.5540267859 -31.7395478111 -44.4980560468 -56.6634843079 -44.3620664398 -41.4420388402 -43.6350575402 -39.4674422559 -46.7234918807 -71.8239333433 -52.4116968143 -42.3893653615 -45.1909382344 -47.1604951621 -62.7687213113 -54.670513683 -59.2021801424 -45.9845617712 -64.7252115284 -56.5238513895 -62.2712208795 -80.5748119672 -inf -65.4650380018 -73.9429634773 -57.8720438035 -53.8949791375 -42.1583148495 -60.0177465705 -inf -58.0304976069 -54.4143825695 -58.5085905673 -50.1008494858 -inf -85.8588252717 -68.0322089628 -52.9203981914 -59.3771320692 -41.6215719439 -59.7140504628 -45.2929227022 -53.9683565493 -39.2593435832 -59.9731494441 -52.7807894205 -58.5090378898 -73.6766748785 -66.8040328848 -64.2185332912 -68.8494938646 -57.7933792372 -44.9556403767 -36.6800631551 -56.9057593434 -inf -51.1425382564 -47.7389821137 -52.0495306671 -44.7546747041 -58.205635663 -82.3305385935 -57.5988372644 -48.4552162397 -56.2737286004 -47.1385853501 -66.4504788126 -54.0658757614 -57.0859549443 -43.8555657865 -67.038919175 -55.4363616659 -62.8577075748 -79.5205782299 -inf -67.0233852368 -70.8427809055 -63.6379343689 -49.4751152192 -42.322810424 -61.7379368618 -inf -56.8758464216 -54.9711132289 -61.0477670633 -51.07624774 -64.7481572802 -86.0333321874 -inf -54.6018935863 -61.4299558579 -35.5747948895 -46.7639977008 -33.9252648132 -40.1049241106 -29.9187868546 -44.4375884122 -35.3196695875 -41.9232968577 -65.0602129985 -52.8897720718 -46.3546373946 -55.3661560369 -42.0607877479 -35.1025699652 -29.0969259419 -40.9411581325 -inf -40.083337104 -36.2874754061 -38.9700848241 -35.8450375501 -40.5064836707 -67.1797060596 -48.2459704112 -37.3538445183 -40.8313554591 -30.3510932608 -51.3866699303 -35.6263346646 -40.9872710141 -27.0030908866 -39.6734093293 -37.3184041812 -45.142477092 -61.5719791001 -inf -47.0553603483 -53.8173257198 -43.3979757531 -33.5491520424 -24.3849104192 -42.6516503151 -inf -40.1407406809 -36.0155057552 -39.988098592 -33.50139844 -inf -68.3270703531 -48.6143031557 -37.532820321 -43.0995397085 -33.0113650082 -55.1245827018 -40.371509928 -42.986859404 -31.6019889939 -49.6040532882 -37.881892899 -51.6529785633 -65.0661096795 -inf -52.5049898896 -60.5647440843 -50.3939850769 -34.9273976468 -28.6446742855 -47.121176548 -inf -42.6185428937 -42.7478679816 -44.3173006364 -36.1629820307 -inf -74.9737040439 -55.8179518066 -41.6072053037 -45.972455044 -52.7799184439 -70.5307929319 -51.5577573973 -62.4788744398 -49.8302016057 -70.730575303 -52.4263645741 -66.4386123423 -88.0264491666 -inf -67.7917091529 -78.6396434652 -66.6364433088 -56.6296275755 -46.7233592891 -60.3728923325 -inf -62.5382515573 -55.0868604088 -56.9300622997 -57.729783072 -inf -87.0126184454 -68.9215769437 -57.960165469 -62.0823945807 -47.7090470509 -63.3157957097 -50.8171512967 -56.5052528597 -47.1692072578 -60.0894429521 -52.606075809 -59.3616413496 -86.5284827518 -70.7860903048 -63.6879264139 -71.2403395736 -59.012535812 -51.9126740234 -43.0751781187 -58.1051634332 -64.7561881085 -56.8395261659 -52.5513579468 -54.8912670438 -51.818507109 -57.9880094236 -84.5267520353 -65.0372654011 -53.4668656159 -57.6268910278 -61.7151290888 -76.009130361 -71.5069573301 -71.2659549133 -61.5059803822 -inf -70.4909766488 -80.660194274 -97.1796046896 -inf -81.2149540773 -90.8030612612 -78.4849100155 -66.8508634101 -57.2075263765 -74.0940711022 -inf -74.2990709569 -72.4229130103 -74.4771958459 -67.5006826278 -inf -inf -inf -inf -inf -45.8336701001 -67.4261930684 -48.021202855 -60.4526841602 -45.3218691456 -62.6153401404 -54.3339373352 -63.1969032682 -80.0736502203 -inf -64.5989608861 -71.639292611 -63.7942077498 -49.8946607855 -41.0441274372 -59.7710935994 -inf -55.0723537123 -51.8941159003 -59.2756679006 -52.7280632058 -64.536705843 -84.7540401063 -inf -54.8590079683 -58.5794470721 -38.6940373456 -53.8342854399 -43.4307329803 -50.4951225919 -37.6312733953 -53.646337711 -45.3257910633 -54.4635876347 -72.0113175666 -inf -57.036828254 -62.4432609047 -54.5580986239 -45.5008822927 -33.8063260407 -49.1435956361 -inf -50.1857921877 -46.5826242129 -49.0298130176 -42.5987031509 -54.9413445138 -77.6033813778 -61.2188279934 -46.2629745938 -52.0560071423 -59.8487436514 -77.3967675452 -67.3073639565 -70.0129742363 -57.6079588419 -76.0519726393 -66.7728343038 -74.4295684704 -92.7701443005 -87.2752455195 -79.1053102072 -85.6285631402 -70.6664104818 -65.009553444 -52.9646680509 -70.7276996151 -inf -69.1633552452 -66.0393944768 -69.0849125495 -63.1019068796 -78.0482396689 -98.1597670735 -79.3975037567 -64.9562125853 -73.1895931679 -57.828319231 -79.6628696445 -68.2420014045 -71.387807592 -55.8671961503 -78.0120520428 -64.0316860157 -73.1955332705 -90.4867333202 -87.2996712889 -77.364137314 -87.5156324678 -74.262114345 -64.3068066783 -52.2220409198 -75.2811341808 -inf -69.0659565169 -68.0644080805 -70.2008226485 -61.9116086641 -76.5685880049 -95.0384492113 -80.4515489216 -65.3880906824 -73.45518098 -42.4850485333 -52.1331881065 -40.3355924557 -48.1132120093 -37.6557305932 -50.445313389 -42.9767826697 -49.3175581547 -69.7305919388 -58.2956134557 -55.7119291452 -61.8916669458 -49.2274685146 -42.3578767217 -33.0208396207 -46.4279338708 -inf -46.3228653273 -43.0845129348 -45.7191161161 -44.1786774287 -49.4279966827 -72.8594860041 -56.3969767094 -43.5559694712 -48.3263908766 -24.1894679215 -42.9441538459 -33.8981913748 -36.9655259393 -22.1046750302 -inf -33.3746872043 -41.9528160114 -57.550027265 -inf -43.1097511983 -49.624175935 -33.5539272281 -31.4233216769 -18.4387081421 -32.7436751318 -inf -33.3841400472 -29.4067884374 -35.2860206135 -27.2920916647 -inf -63.8244462078 -38.5848385229 -30.0472785314 -38.0127586616 -45.405935532 -inf -45.6752389451 -54.4579328338 -41.7297175066 -inf -54.1068817849 -58.9008209848 -77.7415086207 -inf -inf -inf -inf -49.3319531992 -42.3466482352 -inf -61.707397883 -57.368432369 -51.6821092836 -59.0093916826 -50.8983341698 -inf -inf -63.4304372977 -inf -56.0593759123 -32.0301800703 -49.4129399516 -37.0568914293 -42.5595393946 -29.7416496731 -47.9876416309 -37.8344398818 -45.7324374284 -66.1608664795 -61.4408180294 -51.6699314267 -60.3676486251 -50.3453027909 -41.0700696711 -26.4641247158 -43.1630819367 -inf -43.6940956148 -41.7080150632 -41.5129139019 -35.6132400878 -48.3219918938 -71.5870424557 -inf -40.8729722015 -48.3847851007 -39.064576766 -55.4164541453 -44.8451644625 -49.0384989405 -36.5228327668 -54.8237430079 -44.6531662703 -53.8532519924 -72.1157669759 -67.1265469244 -55.2285453132 -64.1787535651 -51.6370831578 -43.1464575975 -34.2486933292 -50.5982498665 -60.6348266984 -48.378401536 -44.3240773477 -47.3356461049 -42.310386397 -56.1503412148 -76.3001329321 -61.1947153044 -43.584523016 -54.5813396356 -32.943738337 -50.1322585722 -36.4545649815 -47.0448336 -32.0216581996 -46.4295327486 -40.1898311217 -46.0784600343 -66.3321130283 -inf -54.2830182414 -59.2236676672 -50.6293033636 -36.579943381 -29.1116391984 -44.5117464072 -inf -43.1849051105 -37.9261913797 -43.1121530901 -36.7107022105 -inf -71.9948635508 -49.9580418993 -40.9759175523 -49.277375482 -49.8632524493 -64.3525452032 -51.8688594751 -57.7033673452 -49.7971661253 -62.3465003624 -53.5584851083 -62.7512976868 -84.876197225 -70.0124067558 -67.7510588865 -73.4473457635 -61.4029155801 -53.7349581871 -42.1497962506 -59.2811043045 -60.565431922 -59.164756785 -54.0563390047 -57.325505119 -58.3481965221 -64.5397375501 -90.1687178604 -67.4100285974 -58.5776421873 -60.3997715499 -47.4514043733 -65.253646979 -inf -57.7498893911 -45.1437293327 -inf -58.4480098551 -65.1768094003 -79.6239979718 -74.8428312904 -68.7383512694 -72.6187024241 -64.4137949623 -51.7596943088 -41.9224857274 -inf -inf -57.7315526089 -57.5585673094 -62.3209003409 -54.7053797464 -63.4757592443 -inf -68.6878561311 -57.054131565 -61.7867983436 -74.8490093331 -92.9129340361 -84.4877980657 -85.2118764928 -72.0929345566 -92.1011154731 -82.6733097025 -88.5933180416 -110.630942991 -101.147572673 -92.3651198883 -100.765511713 -90.6672430366 -80.2699590902 -67.8473515042 -87.5604196602 -inf -85.6221647313 -81.500098942 -83.7412177399 -81.7972001612 -inf -inf -92.6223537433 -80.6129524744 -86.4051407804 -40.1342754105 -inf -inf -inf -37.9200367169 -inf -50.2159449973 -inf -71.943127955 -inf -inf -71.9143239449 -inf -47.5249123264 -36.1175354142 -inf -inf -53.5502549272 -inf -inf -46.0794106173 -inf -inf -57.5026185685 -49.6462421415 -inf -36.2336161641 -53.4486118553 -40.6616891304 -46.7263002664 -35.3523281215 -51.1692723339 -42.0606314302 -50.8619198479 -75.8852421007 -inf -53.4934768708 -59.8320902036 -49.9561607504 -40.4668502252 -32.9592668374 -48.9807154314 -inf -46.0593056347 -44.326962422 -43.8954511839 -41.360195762 -49.293178084 -74.2828216559 -55.6542888722 -49.4582087497 -47.7200760276 -35.655321523 -56.1236520099 -42.2178771118 -48.4082057352 -34.7695965728 -51.4558999287 -44.4977333276 -53.162873525 -67.4087589897 -inf -55.6635434505 -62.1399889201 -inf -40.5616201417 -31.5488613039 -51.3589243106 -inf -48.3523476046 -44.5772855611 -44.4839186101 -40.4335195986 -51.4424053304 -77.0713856407 -inf -42.0874808059 -43.6430863712", 
        "==", 
        "name: None", 
        "var: 3 4", 
        "card: 26.0 26.0", 
        "val: -44.4816798694 -48.0701903643 -41.6669516864 -46.6997452621 -36.3075707167 -30.416380825 -34.242725375 -50.91788159 -51.1354838772 -64.5556433232 -46.9199831873 -37.8765294708 -58.0418386711 -57.1537066476 -42.2227920498 -23.40407544 -46.1615316029 -31.4446802806 -39.5014643202 -33.9228257207 -49.3900754452 -47.5581883645 -74.3172812067 -41.9325030971 -39.6449871537 -35.3271384909 -46.3501375201 -55.2830613347 -53.5041976539 -56.4327290125 -44.492705315 -41.154021804 -46.4152534283 -62.1662352797 -58.4416704868 -inf -55.1671906046 -48.3468357754 -64.8648621485 -67.0886270841 -48.2355272309 -34.5177340872 -inf -40.7070795396 -48.067776198 -44.390326897 -55.6174508307 -inf -83.9461412809 -53.1469833901 -45.7699881066 -45.1073004513 -42.5817269232 -53.998903084 -45.8971192062 -52.9694179882 -39.5379996881 -38.172472208 -44.4427040098 -60.1745648058 -53.3140460032 -69.9756716228 -55.6911984584 -45.0238787751 -66.556710156 -59.919800921 -44.527788136 -33.1762594455 -inf -35.5896328476 -43.1628883211 -39.7017795264 -52.0417885943 -56.4048128265 -82.188367175 -44.4841242543 -43.075318721 -43.7744095364 -42.4931566013 -55.1297477005 -49.0644885825 -50.4814326822 -38.5286382147 -39.6326582875 -41.4926925578 -58.9176508315 -53.5523656454 -inf -52.8904667604 -41.4115821382 -66.7956816057 -58.8336920795 -44.5649516888 -32.402853278 -inf -35.7173572477 -44.7894357206 -43.0944322946 -52.757777976 -57.3417507629 -80.2855770619 -inf -43.6164124086 -43.3250530696 -39.7517747427 -44.2656751908 -37.7462862251 -42.322810424 -33.4142678538 -25.8537361118 -30.1984090634 -46.8056486971 -47.9144090426 -59.2782357331 -41.0441274372 -34.7573658464 -54.0409435868 -53.2835554416 -40.1614758586 -20.42848314 -inf -27.7472565034 -34.9282065133 -29.8391586118 -46.3489763701 -41.9224857274 -70.2543595382 -38.3480823305 -35.1907719205 -31.5488613039 -44.3440548721 -58.7043291826 -49.2633378359 -53.0211390887 -40.3145536574 -30.9055388273 -42.013125436 -59.8408107279 -54.2421568805 -inf -51.5608322146 -43.0245172922 -65.1941133304 -61.5461192763 -45.2654420153 -31.9549570408 -inf -37.6206418963 -44.472218636 -40.6731541508 -53.8213190008 -inf -81.2177056355 -48.532396725 -45.1857294763 -43.6330273293 -38.4256189869 -53.8635343038 -45.429805475 -46.4420198376 -36.3347441287 -32.2574751495 -33.9979065139 -57.7726045714 -49.1575798645 -inf -48.4317540923 -41.1932279974 -63.6114150046 -54.345657223 -40.9464982504 -27.8457756429 -inf -31.5197364695 -42.6258731664 -36.4236485315 -47.9041949414 -inf -79.28563164 -47.1573378036 -40.6814067897 -37.9272350068 -48.6089323885 -59.6845045165 -47.0308129038 -56.3487948414 -44.9777166894 -43.798757133 -38.9571381701 -62.9729982774 -62.5326792641 -inf -54.13323333 -49.6828873398 -70.2686332344 -66.4626471259 -49.4399432348 -31.5122514113 -inf -41.8542050796 -45.3796256255 -39.4511701754 -59.8857559524 -inf -81.739306015 -50.6757229233 -47.4491269396 -44.4519345272 -58.9247114787 -67.8561577744 -61.6768572647 -65.7618237469 -57.7033728248 -48.5442752699 -54.5234998696 -71.2826777819 -76.4213633439 -84.2132385169 -65.4161010668 -57.670233959 -78.0313762171 -77.1323440627 -61.1784125585 -44.6311729915 -61.8742255838 -51.5421301644 -58.2307736237 -52.7990254073 -69.3611304869 -66.4426960558 -94.6400900848 -62.1780618301 -58.3424775784 -55.383081425 -57.4040923707 -65.022791266 -66.8399622039 -64.9958246669 -56.5134448487 -inf -56.8816996138 -77.0545295833 -71.5457841592 -inf -67.4164275851 -61.7062544896 -81.9770492736 -76.5438322733 -59.7840596749 -45.0933795336 -inf -53.4749738582 -62.5756275435 -56.858253061 -69.5166048778 -inf -inf -inf -inf -inf -44.6810382153 -59.5982587734 -46.5126125395 -57.3409587194 -43.487738361 -38.7018761224 -43.8830650614 -62.749643394 -57.5982344913 -inf -53.9588392361 -45.7008906765 -70.4447518026 -62.7460344877 -46.7790655221 -33.9288068584 -inf -37.4066613888 -45.2052352794 -44.8151299424 -57.9023902665 -60.6230961667 -82.4990818384 -inf -47.3663236186 -43.9673411663 -53.7282027915 -62.1931484975 -58.1089400089 -63.5701945435 -51.9839399959 -45.9196710795 -51.0617161567 -70.2031251071 -65.7226992192 -inf -62.5835039374 -52.6916563102 -77.3954400673 -74.5390533357 -55.7280614922 -39.4881062395 -inf -48.7068972428 -56.0805409358 -50.7560723992 -63.9598275707 -67.2145321545 -91.5352204821 -62.1781254941 -54.9570875712 -53.6306985895 -34.5816466019 -45.4543681021 -41.684308479 -42.7867836668 -31.6593629347 -28.0240434757 -32.2074968844 -49.8678434556 -46.1802634371 -64.2196322749 -44.350723398 -35.5756960496 -53.2024894227 -53.746461989 -34.5851409913 -20.7709477159 -inf -27.3831977892 -35.2360487056 -30.5099094866 -44.1617687831 -50.0201647909 -71.7903436319 -40.0555387434 -33.3490630996 -34.463022107 -31.7395478111 -46.8987959187 -41.7972716113 -43.3399426849 -29.0969259419 -29.1624485491 -28.6446742855 -47.8121339127 -43.0751781187 -63.4223837171 -41.7878761817 -36.6410910429 -55.9765189589 -52.2220409198 -33.0208396207 -24.5027079575 -inf -26.4641247158 -36.4393879721 -30.804145226 -42.1497962506 -47.718838877 -67.8473515042 -40.2879096061 -32.9592668374 -33.906935607 -39.1854776668 -42.1583148495 -36.6800631551 -42.8545476066 -33.6746608829 -24.3849104192 -30.3789714405 -46.7233592891 -45.108237237 -57.2075263765 -42.9248684822 -33.8063260407 -53.731073615 -53.0623114742 -36.6088387573 -18.4387081421 -inf -26.5102340021 -34.2486933292 -29.1116391984 -47.206065475 -43.3674480105 -68.4575887545 -39.0225378733 -33.9163461148 -31.5673459856 -35.7970327989 -47.8764163606 -45.1497978099 -46.6139973037 -33.0307409779 -inf -35.6840116765 -54.265752922 -47.8348083019 -inf -45.2298263053 -36.4459707397 -52.9646680509 -57.0348921564 -36.9338430249 -19.6615851218 -inf -28.4786445034 -35.4781045597 -33.585679441 -45.2266154911 -inf -74.3296847027 -36.1175354142 -35.3147909498 -36.160849517 -52.2841681593 -inf -52.1975131602 -59.3770719092 -47.9264513224 -inf -51.6868740932 -66.4844256248 -63.2969574336 -inf -inf -inf -inf -70.2141914184 -56.1124508646 -inf -54.4880036048 -47.7336045794 -53.0240931824 -52.579718294 -64.1035257755 -inf -inf -56.2338019788 -inf -49.4781345299 -40.7678117132 -51.4752692462 -45.4385646577 -49.3380775295 -37.797782501 -33.9644411588 -37.2738311913 -55.17544109 -53.5757143367 -72.3899335031 -50.9200733083 -44.3195102331 -66.8861104649 -63.811706984 -42.0893264013 -27.2110588001 -inf -35.9186668772 -44.9093979968 -36.9426395249 -50.6778307245 -54.2986457465 -79.2223477437 -inf -43.2705514035 -43.6629427612 -47.316830678 -56.9934057016 -52.7414599524 -55.331659308 -44.0935878359 -40.3151648253 -43.6071797859 -62.8108779214 -59.0452370528 -77.5902846416 -53.9933094398 -47.6452374319 -67.6925130427 -65.4027171353 -49.3885172613 -34.1608489083 -54.7894536799 -40.1175950102 -47.0400825081 -42.2799939705 -56.8895992932 -61.6416173394 -83.4500604803 -55.3721012696 -45.4967244279 -49.3741195187 -37.1755135444 -47.6887314061 -40.3303817181 -49.3175152623 -35.5719345228 -27.9004758115 -35.1233659704 -51.0156072063 -49.2411043539 -inf -49.0273036764 -38.6696728003 -62.6642545278 -54.8157241779 -40.2309844086 -24.0538667003 -inf -30.9036198679 -36.6217178339 -34.03602218 -47.2694363308 -inf -75.1243122945 -40.1149490749 -38.8676402896 -40.0496766055 -45.1251649977 -52.9391553913 -46.774813568 -51.0061863338 -44.3775797632 -34.8475807588 -39.5221572782 -58.7185821959 -58.8153259031 -67.4858030509 -53.5254816312 -43.9234882602 -64.4680040645 -63.0008762894 -44.2992787377 -29.8533619863 -41.7297175066 -37.9136089068 -43.7820027815 -39.2795115853 -59.9370679406 -57.040672227 -84.3283039928 -48.5970731383 -47.4995022222 -42.2022100349 -47.7058429257 -58.8327831522 -inf -56.0452344038 -44.7166690367 -inf -49.4042080256 -66.1366198946 -58.5556526462 -77.3087536064 -59.5053000274 -48.0873708636 -72.4714094599 -66.0181384421 -49.0644942606 -inf -inf -41.4729307147 -52.2767570885 -49.2674328093 -61.286777251 -60.9692199899 -inf -54.8674266759 -50.9685176243 -48.5817628645 -50.7899820263 -62.1786043532 -60.0728123134 -59.1937556715 -47.3524083973 -45.2812560758 -49.3160420221 -65.2396627277 -65.2491318523 -79.3000291623 -58.8186028429 -51.9207143286 -74.4113917215 -70.2149373336 -50.6758941847 -38.8117375333 -inf -45.0500769784 -51.9048229194 -46.3742843635 -64.0651317858 -inf -inf -54.4884584705 -50.2138726955 -48.8866394405 -40.5887475551 -inf -inf -inf -37.6930100369 -inf -41.3721767699 -inf -51.0748162666 -inf -inf -47.583026034 -inf -61.9833900581 -43.4595775349 -inf -inf -37.4916666372 -inf -inf -52.8608417151 -inf -inf -43.8822227592 -43.7606618542 -inf -38.7396442833 -49.2793375735 -42.8117588026 -47.2732348434 -37.1768573868 -30.9144683257 -35.2684191542 -54.0733199477 -57.0684863565 -inf -46.512015171 -37.5523482475 -60.2653648421 -56.9768839126 -42.3528649648 -26.7970886593 -inf -32.0522733165 -41.2967417697 -33.093573172 -50.1931827899 -49.0382283543 -75.6865234 -44.0854489985 -45.624184362 -36.7666301107 -41.4986384258 -55.2916665067 -47.7052355642 -52.2924290895 -39.9314146145 -34.5383846931 -41.0428098475 -59.71156242 -51.9292920798 -inf -52.0193705756 -43.1975357857 -inf -60.4089426416 -44.2797482209 -32.5125863142 -inf -37.6826040996 -44.8843537037 -37.0193294331 -52.6037954487 -54.5247444239 -81.8123761316 -inf -41.5907452479 -36.0269292059", 
        "==", 
        "name: None", 
        "var: 4 5", 
        "card: 26.0 26.0", 
        "val: -28.7049745206 -40.4343064821 -38.1678448357 -36.2527478101 -23.0660898776 -36.9417061375 -31.7142264824 -35.7114706014 -50.6631164748 -52.446193377 -38.2627395044 -43.5630065766 -25.086409632 -28.5988000285 -24.0573583286 -24.6316492921 -54.2762949399 -32.1502019491 -39.4183168402 -28.8697501094 -32.0420688378 -45.6683679636 -44.676126904 -40.4063287673 -32.5304265798 -36.277075709 -36.4578084307 -53.5315536895 -55.8894670687 -51.8701077787 -37.1356007267 -53.5637233249 -49.7711307603 -52.8442005005 -63.853679331 -inf -52.3943231281 -59.9176891162 -37.7938093696 -44.4180966978 -35.9544697288 -41.6296841728 -inf -47.2969774851 -53.8690048797 -45.2216275171 -44.1538204741 -inf -60.1893632134 -57.5051852833 -44.5398037725 -51.9416138819 -26.8066554457 -46.3646530684 -42.3996462974 -42.5240544369 -26.2981527401 -44.6994314352 -41.915838976 -44.969787723 -52.843312509 -57.8678555419 -47.0355886389 -50.7119898124 -33.6029150133 -31.3665282098 -26.3639883201 -34.4054671962 -inf -36.2967883647 -43.0813747012 -34.6503378249 -34.6954158518 -54.5166263243 -52.5488467614 -42.9595837858 -35.9623920443 -44.7259806316 -31.101033882 -51.8784464645 -49.9499643733 -44.4190178627 -29.6717400036 -50.5425662179 -43.3487762759 -48.0958224502 -57.4645809124 -inf -48.6178056865 -51.4826418666 -38.2248352114 -34.6633680643 -30.7841005665 -38.0150097653 -inf -40.8074615426 -49.0908708258 -42.4259393413 -39.7943539931 -59.8365129772 -55.0290053701 -inf -40.886434458 -48.6595729182 -25.5169925261 -38.1717144462 -35.7891025633 -33.4177361157 -21.7147101502 -33.9209845555 -29.2118333045 -33.1411608451 -48.9839647935 -48.7107088812 -33.9288068584 -41.9857660852 -22.6274377028 -26.2705719322 -23.5379652517 -23.1979801355 -inf -29.9947013513 -36.3869821305 -26.328006143 -30.5428928722 -41.5745884576 -42.1551283449 -38.3638311043 -29.6181344835 -34.0407216369 -37.5761873664 -60.0772831247 -54.7730688329 -51.5829795017 -36.0819106517 -46.4397019657 -48.4934643866 -53.643237571 -62.7786273297 -inf -51.9124262967 -57.7198322536 -41.2475221529 -42.0000505157 -36.1088461688 -42.1913687719 -inf -47.3350013681 -53.3979089597 -44.6289163591 -45.4821502099 -inf -60.5853891377 -56.0150602544 -47.0800067139 -53.5918023616 -25.7366802712 -49.3154170533 -45.0184653111 -39.0827890391 -26.1810299295 -41.8705670657 -34.557174255 -45.6539602218 -51.7729790849 -inf -42.8622770301 -49.9674717622 -33.7437526233 -28.8785172591 -25.8688312144 -32.1611161851 -inf -35.313024775 -45.6304922994 -34.4583395784 -33.6439549636 -inf -52.7322439582 -48.718930092 -36.6546129045 -41.9649388612 -42.0925578249 -61.3089513982 -52.7920368583 -55.1621281828 -40.9965666524 -59.5844131952 -45.6889700716 -57.0269180791 -71.3206426693 -inf -54.7363204083 -64.6296952374 -46.5735349844 -47.1680713049 -40.5348403087 -42.0001560836 -inf -51.8200575504 -54.5568088818 -43.6584253687 -51.7980801179 -inf -61.358482481 -58.4098793439 -49.5948971596 -54.6622024823 -57.3229966328 -74.3952643862 -72.352740925 -69.4898168337 -58.6368824883 -69.2445910343 -66.1699914837 -70.2512573084 -90.1239864673 -86.278779055 -70.9338478412 -77.5317015611 -59.250937744 -62.752427939 -57.187969307 -60.0337373169 -84.1639794003 -66.4226423288 -72.3226165816 -61.9209403179 -66.1881143419 -78.7278661415 -79.173926259 -74.8268779931 -65.4029074958 -70.5080091468 -46.7539298622 -62.5134502246 -68.4673982072 -59.6753700431 -48.3985068467 -inf -59.4797435198 -66.9746614275 -76.1999595802 -inf -63.8857267077 -72.5192744341 -54.1481630791 -53.1154685019 -46.7451687827 -51.4474962719 -inf -59.3070383532 -67.6190228245 -56.9317203027 -57.2951410638 -inf -inf -inf -inf -inf -36.2961909144 -59.3542329669 -50.405363746 -54.2858193598 -37.6381156112 -52.6190594698 -48.746424182 -54.93509044 -64.5177251476 -inf -52.693453557 -58.7792258147 -44.8811808256 -41.5829859083 -36.0054898135 -42.5482387594 -inf -45.5040410958 -52.5139457609 -47.1539123871 -47.94624164 -66.1251337993 -60.2497855707 -inf -47.6436210656 -52.3091363725 -46.2324276179 -62.8381947784 -62.8907633531 -61.4041272443 -47.0233893105 -60.7259265045 -56.8141473976 -63.2776442723 -73.5312619039 -inf -62.2071903704 -66.6590635681 -52.7209411914 -54.2650768965 -45.843557935 -48.9966102392 -inf -57.6933490698 -64.278323558 -53.9839269764 -54.8927510798 -73.6056419086 -70.174996288 -68.9328812937 -56.1234571657 -62.8615659254 -34.7903639322 -53.8039069333 -54.1706243431 -48.3252088999 -34.4033048014 -50.5347914579 -45.664420674 -50.6468551557 -61.6933187257 -68.0956049936 -51.6789023331 -57.2475958476 -36.2324830754 -41.1769780714 -32.4051299112 -37.9839442425 -inf -44.074142141 -51.1383238495 -41.4422565509 -42.7991848397 -64.1157670804 -58.1346120105 -54.5147870454 -42.2199251826 -51.3983819952 -23.8870960935 -47.1871655893 -46.2224183418 -40.8171988412 -23.7796986924 -43.6120274218 -34.0404289204 -40.5299764842 -50.5270642918 -59.2371873134 -41.0548860308 -50.2518217146 -30.9453435022 -31.5913879002 -22.7796594103 -33.6545354009 -inf -35.0938999783 -44.2804940173 -33.6753231855 -32.7260431898 -53.7532719956 -46.1304507349 -46.6859887995 -33.7689598325 -42.7811263678 -23.40407544 -34.5177340872 -33.1762594455 -32.402853278 -20.42848314 -30.9055388273 -27.8457756429 -31.5122514113 -44.6311729915 -45.0933795336 -34.262927895 -39.4881062395 -20.7709477159 -24.5027079575 -18.4387081421 -19.6615851218 -inf -27.2110588001 -34.1608489083 -24.0538667003 -29.8533619863 -41.4729307147 -38.8117375333 -37.4916666372 -26.7970886593 -32.5125863142 -31.8911468273 -52.1113518537 -53.5215103583 -48.037819207 -31.6600795305 -inf -45.0263321774 -50.9301612859 -59.2332602854 -inf -48.4434019589 -54.0032672216 -31.8800584167 -40.3508049279 -30.6392286578 -32.7599784142 -inf -41.0549855328 -47.2657764053 -40.4034232102 -39.7494282323 -inf -56.5593497531 -46.4621804417 -40.0710497354 -48.9816060956 -43.090560157 -inf -55.2815036716 -55.5131718479 -41.2680678313 -inf -55.7414725008 -57.8611119798 -69.4076873768 -inf -inf -inf -inf -48.2423821598 -44.5301144981 -inf -69.1858642383 -55.0222236088 -59.5240429973 -54.1097399974 -53.3386164705 -inf -inf -61.2907249666 -inf -57.0111690771 -31.2851173683 -50.1333963266 -48.2334688239 -45.1850910718 -30.8503126468 -46.7837774765 -41.0393432799 -46.263041075 -59.3973579104 -66.5744945424 -48.5568405807 -56.2999983251 -40.2246923892 -41.5508113151 -30.2179036224 -34.7326436438 -inf -42.9181995572 -51.1202614437 -38.1835749093 -39.6238350628 -58.7028363309 -55.8752044143 -inf -42.4500017918 -50.9068909514 -28.4424576728 -46.2598541429 -46.14468549 -41.7869942227 -27.7544393515 -43.7428224464 -37.9810132628 -44.5067992697 -55.4752020062 -62.3831670581 -42.2383980897 -50.2340468631 -31.639416356 -33.7501428384 -28.1254158911 -32.2907551329 -59.8065493505 -37.7254490534 -43.8592673384 -34.1292506777 -36.4439249713 -56.654129286 -50.7112384982 -50.7482592626 -35.2844961906 -47.2263890855 -29.55668108 -48.210720401 -44.9891477488 -47.0283906873 -30.4883265643 -42.5836739907 -40.7527399288 -43.9670691163 -56.9266098515 -inf -48.5279328103 -52.5140227759 -37.8666983652 -34.4186904147 -30.2234235297 -33.4393134597 -inf -39.7670144052 -44.6964431505 -37.1408194731 -38.0793025934 -inf -53.6410308662 -46.7466476304 -39.9109525559 -49.1574867185 -27.2375833989 -43.1923952498 -41.1648305376 -38.4483126569 -29.0252227273 -39.262029849 -34.8827821446 -41.4012949957 -56.2320823035 -53.2654768994 -42.7573616968 -47.4990891569 -29.4016988265 -32.3350934377 -24.0229687978 -28.9700596107 -47.7336045794 -36.5082543633 -41.5879790473 -32.1155597809 -40.4781851543 -53.0399756389 -52.5762734642 -44.9600225861 -38.2740654403 -41.0412710462 -37.2375317158 -56.5052934081 -inf -50.9066310964 -36.7835823345 -inf -52.1841032743 -56.2386030473 -63.3916793955 -70.5076977869 -56.1564504551 -59.08224215 -44.8243746253 -42.7716259655 -36.2074546686 -inf -inf -47.4868465167 -57.5020037177 -49.5227513436 -49.2471647719 -64.3877937267 -inf -58.6496464719 -49.1623512295 -54.8400942116 -59.797374235 -79.3268180249 -81.3578030435 -73.530855779 -58.8950251298 -76.5906789284 -71.5716406854 -74.8173492752 -89.5608620245 -91.9746767175 -74.9454566529 -82.3912889966 -66.2400602447 -66.4441282866 -57.294558019 -64.8234088993 -inf -70.5396962141 -76.605772987 -66.1053063097 -71.5012227016 -inf -inf -77.7463816818 -67.8834096609 -74.6206742052 -42.1884694814 -inf -inf -inf -41.8279564061 -inf -56.2201051467 -inf -67.9788761702 -inf -inf -70.6459303968 -inf -50.8049107255 -42.6705711243 -inf -inf -55.5736156311 -inf -inf -52.8892623528 -inf -inf -59.7324756767 -54.0225285336 -inf -28.3121377222 -46.9926524578 -44.6618507094 -42.1754361392 -29.2845753217 -42.7889923688 -38.0891190105 -44.2161077389 -61.9453177291 -inf -43.2039702066 -48.5880241516 -32.6591346116 -33.7711760616 -29.5366300347 -33.3738612891 -inf -38.106993741 -46.5627930241 -33.3896963912 -38.1943749371 -52.49760675 -51.3945678185 -47.9084734036 -43.8588225671 -43.0657660675 -38.1421921753 -60.0760417852 -56.626387875 -54.2656908035 -39.1101929188 -53.4839691505 -50.9345700952 -56.925410588 -63.8771838151 -inf -55.7823860094 -61.3042720085 -inf -44.2742951719 -38.5345736336 -46.1604193468 -inf -50.8083849044 -57.2214653252 -44.3865129775 -47.6760479807 -65.055183164 -64.5914809788 -inf -46.8964438058 -49.3971255697", 
        "==", 
        "name: None", 
        "var: 5 6", 
        "card: 26.0 26.0", 
        "val: -35.5740500279 -42.3743653182 -30.566755401 -36.3829368874 -29.2718039542 -41.5262376223 -31.715336791 -43.9849548955 -64.6213270579 -49.0536383945 -44.2752744278 -51.4179608886 -38.0975664141 -29.8737598634 -26.6160938528 -35.2255661064 -47.9832566483 -36.8880997914 -35.5589321429 -36.5426237672 -31.8665558954 -37.4671366227 -63.5048896598 -43.7314691597 -37.8035113283 -39.4383220497 -33.0201695693 -45.1648982223 -37.9816633328 -41.6935825733 -33.0346005145 -47.8415404986 -39.465526724 -50.8109705066 -67.505175616 -inf -48.100143808 -57.4659291375 -40.4982518855 -35.3863422413 -28.2064909587 -41.9168866824 -inf -41.7281610313 -39.7029059164 -42.587786877 -33.6715932626 -inf -68.711411691 -50.5236113594 -39.5061742671 -44.7961459651 -35.3730990231 -50.0020800073 -36.4959249373 -44.3516115837 -34.2012349389 -50.9813310259 -43.6143173919 -54.9406401352 -68.4988911782 -56.1726686747 -54.7454916895 -60.2643121719 -48.3114399056 -34.3388561394 -30.6200919278 -46.6967520593 -inf -42.7320543068 -40.9193580794 -44.020579588 -36.2172710597 -48.0127630791 -73.0749776504 -47.9820922867 -42.9328449051 -49.5845951056 -42.5715700743 -58.41996597 -46.9503356482 -49.1506676501 -40.4789148279 -59.7285584388 -47.9513472929 -60.9707674967 -76.0242521778 -inf -59.2318013565 -63.939056906 -55.8374527052 -40.5397886058 -37.9442968322 -53.2103872844 -inf -50.1468201073 -49.8329468193 -54.700273692 -44.2203017992 -56.2367423676 -78.4592288724 -inf -50.7609799168 -56.422280028 -36.1564937739 -43.8821990313 -31.9584388342 -37.3183509684 -31.6908500139 -42.275941812 -32.9833693358 -45.1850709185 -66.7126011149 -49.088579688 -43.7117675884 -53.6111461927 -39.4090202259 -31.3159575522 -29.8671265323 -37.5623227103 -inf -38.503024931 -36.2980231981 -37.7713055461 -34.1378057092 -37.1437828857 -64.7543168993 -45.4593972473 -38.6616450702 -40.972393796 -39.4602045556 -57.032283703 -42.1869211378 -46.7281102872 -37.3025664677 -46.0391751604 -43.5095163745 -56.9316635911 -71.7517796229 -inf -52.9399029996 -60.5897282554 -49.2736206367 -38.2899520646 -33.6825233984 -47.8002273109 -inf -47.0878409374 -44.5534659733 -47.3167317272 -40.3215790171 -inf -74.4290935761 -54.355142365 -47.3680331965 -51.7679904505 -29.6978521294 -48.3475722674 -34.5094722065 -36.3050744818 -29.4788403968 -43.5471949162 -31.6503809055 -51.0195409024 -62.823285997 -inf -45.9669083572 -54.9145224952 -43.8470057676 -27.2455734592 -25.519663059 -39.8471293441 -inf -37.1430189956 -38.863203964 -39.2233095867 -30.5605384152 -inf -68.6531030951 -49.1361668597 -39.0197940378 -42.2182816064 -36.6349682088 -50.9223451525 -32.8642823152 -42.9656521615 -34.8756155929 -51.8422795874 -33.3634152234 -52.9737372802 -72.9521881472 -inf -48.4221902429 -60.1579844601 -47.2580266901 -36.1163660195 -30.7669107066 -40.2674077768 -inf -44.2312902775 -38.3707590635 -39.0046339175 -39.2959020905 -inf -67.860580153 -49.4083546519 -42.5413168326 -45.4967837827 -45.7200653596 -57.8633164563 -46.2796447483 -51.1479991514 -46.3705898392 -55.3571157903 -47.6990949994 -60.0527348612 -85.6101902815 -64.4142173234 -58.4743760628 -66.9146491159 -53.7900877585 -45.5553810342 -41.2746980836 -52.1556474245 -59.3989344042 -52.6885334175 -49.9912251585 -51.1218072255 -47.5405947102 -52.0546280503 -79.5306823225 -59.6800116608 -52.2039855442 -55.1972487836 -42.3000214301 -53.1305251918 -49.5433248581 -48.4825752326 -43.2812370215 -inf -48.157869929 -63.9251618258 -78.8351862654 -inf -58.5752777644 -69.0512448538 -55.8363359896 -43.0674444805 -37.9809204164 -50.7184291639 -inf -52.721952277 -52.4366542714 -53.2816100213 -45.7966442732 -inf -inf -inf -inf -inf -42.6837797109 -60.8128051265 -42.3227876457 -53.9345217216 -43.3623430257 -56.7221042673 -48.2660478044 -62.7270880708 -77.9944490508 -inf -58.2245018563 -66.1526934617 -57.4108509194 -42.3764590857 -38.0827386906 -52.6606689196 -inf -49.760452281 -48.1730743985 -54.345299374 -47.2892421144 -57.4424157983 -78.597061671 -inf -52.4352191551 -54.9888961282 -38.4148390065 -50.091589551 -40.6030098041 -46.8476522696 -38.5424393266 -50.6237939326 -42.1285936262 -56.8644645102 -72.8028084744 -inf -53.5330612844 -59.8273538323 -51.0454339091 -40.8533726763 -33.7156294013 -44.9038629819 -inf -47.7445828326 -45.732274798 -46.9701365396 -40.0305741251 -50.7177465232 -74.3170949985 -57.5713576181 -46.7098779 -51.3361482614 -41.4685008844 -55.5530272241 -46.3785963667 -48.2644594681 -40.4180803426 -54.9283844133 -45.4745924424 -58.7294009384 -75.4605907647 -64.5121114869 -57.5004987976 -64.9116116708 -49.0527013375 -42.2609993617 -34.7729269377 -48.3869225465 -inf -48.6211014328 -47.08800063 -48.9241916665 -42.4327333962 -55.7235972288 -76.7724362742 -57.6489889416 -47.3020714436 -54.3686898189 -30.3265267644 -48.6975796546 -38.191684155 -40.5177431246 -29.5557679911 -47.766914129 -33.6118944397 -48.3738160036 -64.0556300856 -55.4149875548 -46.6377762358 -57.6771312581 -43.5268554956 -32.4367029304 -24.9087501739 -43.818807435 -inf -39.4021530223 -39.9914645446 -40.9185520775 -32.1208855062 -45.122395906 -64.5295687434 -49.5814844316 -38.612399837 -45.5127279681 -35.5961295769 -41.7807716338 -30.8981487214 -37.8560210317 -31.9571759672 -40.8130489968 -33.1698646421 -45.1087144261 -63.9123622452 -47.0238032537 -45.5984415376 -52.6660392695 -39.1050831852 -31.1006465074 -26.3204223854 -35.5784805992 -inf -37.2719353412 -35.6244429043 -37.0497190686 -35.0008277681 -38.5946780985 -62.9634790204 -46.1397857391 -37.3931521485 -40.9968113832 -41.1282025803 -56.41939097 -48.2884012006 -50.5359885918 -40.2337739029 -inf -47.3954227098 -61.5716258496 -75.5594511278 -inf -56.8239171953 -64.2262017851 -47.2591954591 -43.9937450224 -35.5659444508 -45.7218754705 -inf -48.1608636682 -45.7743719816 -50.4442771342 -41.9418956058 -inf -77.7560928108 -52.1553010994 -47.712114803 -54.5108327663 -40.1969925228 -inf -37.9177711417 -45.8807178022 -37.7111388138 -inf -45.9799396946 -56.371953189 -73.603254871 -inf -inf -inf -inf -39.7546989033 -37.3262069221 -inf -53.1301828817 -49.9974783533 -45.9020152284 -52.0199705654 -43.400460476 -inf -inf -54.853222281 -inf -50.4097723534 -46.26332709 -60.1825894133 -48.7415136091 -53.4244143678 -45.1651609721 -59.4774431646 -49.1495877854 -62.6456596394 -81.4647027272 -71.2910737839 -62.6785097865 -72.2640868708 -61.3449833926 -50.9349053752 -40.885773384 -53.4356946988 -inf -55.7652316089 -55.3700109664 -53.965582778 -47.5574564003 -58.61073922 -82.8131014141 -inf -55.8322208302 -62.1772715625 -23.0660898776 -35.9544697288 -26.2981527401 -29.6717400036 -21.7147101502 -36.0819106517 -25.7366802712 -40.5348403087 -57.187969307 -46.7451687827 -36.0054898135 -45.843557935 -32.4051299112 -22.7796594103 -18.4387081421 -30.6392286578 -41.2680678313 -30.2179036224 -27.7544393515 -29.55668108 -24.0229687978 -36.2074546686 -57.294558019 -41.8279564061 -28.3121377222 -38.1421921753 -30.8558845623 -44.5809072407 -31.8181863381 -41.5887077801 -31.1241686646 -41.5983335034 -35.1839782398 -46.6706814035 -65.3149484136 -inf -48.9705957988 -54.7991051215 -45.3079831566 -30.1237783089 -27.2122870843 -38.463358281 -inf -38.9350402605 -35.2671864784 -39.2438211399 -32.3339176904 -inf -66.8999216351 -44.5019160483 -39.6141653664 -46.7488610933 -34.5710226328 -45.5968178235 -34.0281048091 -39.0428654821 -35.6953005156 -44.3109250596 -35.3482561507 -50.1391430244 -70.6546565629 -50.3372856151 -49.2342604004 -55.8184072031 -42.8772193344 -34.0744170055 -27.0460680369 -40.0283401368 -41.9049300723 -41.7105159598 -38.1929580485 -40.2527971474 -40.767035961 -45.3031080308 -71.8693999559 -48.749526702 -44.0115139445 -44.6668811333 -41.7708597657 -56.1096048171 -inf -48.7010727408 -40.6535489691 -inf -49.8494661419 -62.1763399373 -75.0141425665 -64.7793953731 -59.8332379726 -64.6014490422 -55.4997839364 -41.7108383675 -36.4304427656 -inf -inf -49.8889969531 -51.306871583 -54.8598775701 -46.7359044184 -53.8508149533 -inf -59.6390394304 -52.0996885458 -55.6655931814 -70.5335870569 -85.1340142311 -77.6238509007 -77.5281821759 -68.9678765397 -85.0423477371 -75.4398883246 -86.9579709394 -107.386209924 -92.4492591146 -84.82512897 -94.113380655 -83.1183543599 -71.5862254974 -63.7204308907 -79.2844630755 -inf -79.1447314048 -76.6135255825 -77.6453173178 -75.1928471588 -inf -inf -84.938659413 -77.0236317608 -81.6490579265 -33.0263843129 -inf -inf -inf -32.0025098821 -inf -40.1900547857 -inf -65.9059260953 -inf -inf -62.4697241076 -inf -36.0487098661 -29.1981459446 -inf -inf -44.2803527962 -inf -inf -36.682588814 -inf -inf -47.0264554537 -43.2644526477 -inf -29.7464678714 -43.4979660026 -31.6260159964 -36.8708799748 -30.0555441 -41.9387785509 -32.6554839871 -47.0548467211 -70.4687830264 -inf -43.7817598694 -51.0082331533 -40.2355460938 -29.611390592 -26.6606202058 -38.5330327841 -inf -37.410146279 -37.2686630106 -35.6278247557 -32.5841166902 -38.8616301116 -64.7885852964 -45.7988684997 -43.6971620406 -40.7922671469 -31.7846201822 -48.7894531357 -35.7986509452 -41.1692323861 -32.0892594925 -44.8418531202 -37.7090328681 -51.9722473821 -64.6087468924 -inf -48.5682734758 -55.9325788222 -inf -32.3226074913 -27.8666616383 -43.527688659 -inf -42.3196352529 -40.1354331195 -38.8327391177 -34.2738875533 -43.6273043196 -70.1935962562 -inf -38.9428811003 -39.3317244089", 
        "==", 
        "name: None", 
        "var: 6 7", 
        "card: 26.0 26.0", 
        "val: -40.9698880466 -35.6355777717 -39.0042897812 -42.9624033939 -37.6503905745 -43.2460562371 -31.6866503756 -37.7168129683 -50.216705442 -43.8994997704 -44.5997662173 -39.9701139667 -39.4149937917 -34.2943605049 -35.3598579283 -41.9637809931 -46.4356320855 -48.474461666 -28.3660825195 -34.1467184387 -36.2143350313 -42.7073171805 -69.961027617 -38.0633278098 -34.4855949579 -33.5664419522 -46.7067646858 -46.7168677715 -54.7099547471 -56.5638061814 -49.7039442178 -57.8521162159 -47.7275973842 -52.8335856457 -61.3913110718 -inf -56.7153926027 -54.3088392751 -50.1064362595 -48.0976999468 -45.2410121046 -56.9458586811 -inf -61.6052799566 -40.8008133683 -48.4826385994 -46.3101294179 -inf -83.4583067008 -53.146227099 -44.4790149542 -47.2150229208 -34.0270092873 -36.5213647212 -38.1915315373 -44.1891503758 -35.8378937571 -45.9592219111 -36.843703208 -41.9305704226 -47.3523418014 -44.2766023016 -48.3280557326 -42.0745374948 -42.8869395166 -32.0175289714 -32.6219282428 -46.6930392587 -inf -47.5764884315 -26.9845807302 -34.8827465133 -33.8231223994 -46.5110158862 -72.789187815 -35.5720231486 -32.8730007763 -36.9707872255 -38.5626595509 -42.2764298981 -45.9831214412 -46.3253856468 -39.4527528762 -52.0436285406 -38.5179123192 -45.2978770336 -52.2148820532 -inf -50.1515445643 -43.0864614413 -47.7501315148 -35.555640685 -37.2833123283 -50.5438536346 -inf -52.3284334236 -33.2353486762 -42.8996198264 -39.1633323374 -52.0721743751 -75.5106183064 -inf -38.0383150079 -41.1456513381 -35.5988111536 -31.1898908673 -34.4424525194 -37.9442968322 -34.1159159668 -38.0422397851 -27.001162279 -32.9634083272 -46.3544588601 -37.9809204164 -38.0827386906 -36.2097785927 -34.7729269377 -29.7830375074 -32.6573699474 -38.3470169628 -inf -44.1358661684 -23.1516528959 -29.4218795774 -32.5320641613 -36.4304427656 -65.2569341964 -33.8377352565 -29.3902079838 -29.1469930127 -35.1837930811 -40.6212466081 -40.9522059878 -43.6353273106 -36.008903589 -38.0867443012 -33.8085804577 -40.9912721816 -47.6749084848 -inf -43.5921452658 -39.4696318482 -40.9187984835 -33.0383031671 -32.7540379532 -44.8661926989 -inf -49.0019533323 -27.6883668068 -35.24857691 -34.9971086315 -inf -71.2129820784 -39.0147515175 -34.3778673056 -36.223860847 -32.3545604826 -38.8696550659 -40.2078769011 -40.1454113561 -35.1182973555 -42.5278838912 -28.8825648239 -42.0122692901 -45.6795347839 -inf -43.5522704324 -40.7275458256 -42.4253034546 -28.9270443934 -31.5242975068 -43.8462145763 -inf -45.990251194 -28.9312246732 -34.0882746327 -32.1691878626 -inf -72.370111392 -40.7288958513 -32.9627479694 -33.6072718342 -49.3944664721 -51.5472178672 -48.6654769294 -56.9087789667 -50.6178625085 -60.9257584861 -40.6983890742 -54.0692556049 -65.9112268065 -inf -56.1103422771 -56.0737977699 -55.9391142822 -47.9006269009 -46.8743350391 -54.3692829344 -inf -63.1813123943 -38.5415697249 -43.9723888395 -51.0073414762 -inf -81.6803783611 -51.1038735596 -46.5870607047 -46.9885639541 -34.903329982 -34.9119555323 -38.504605712 -41.5148922758 -38.5366030649 -40.8643610303 -31.4578351875 -37.5720195154 -54.9929952909 -43.0475052968 -42.5862944155 -39.2542287998 -38.8949416991 -33.7634082306 -33.8058887377 -42.6812889166 -41.6387364092 -48.062321888 -26.5858021159 -32.5133284944 -35.6758004137 -41.0822352317 -69.7742468317 -37.7992969269 -32.6734957537 -33.1127952648 -43.8368207097 -42.5326988967 -54.1218204455 -51.2030029673 -47.8007848485 -inf -44.2701447625 -53.7979811144 -60.5715258901 -inf -55.0407307403 -53.7443591524 -53.2947245662 -43.6290063106 -42.8656457283 -53.5976053293 -inf -60.4492753972 -41.3847659079 -47.0266659753 -46.2853846086 -inf -inf -inf -inf -inf -37.7924766358 -43.7868765086 -40.473180918 -50.2268471946 -41.4537885573 -48.1547818391 -37.9502202947 -46.1718050331 -53.3026863441 -inf -48.2618525546 -44.4177054738 -48.4411372281 -36.5099185969 -36.5393616973 -49.1117427296 -inf -51.0596730769 -30.6930837121 -41.6622529828 -41.3498801266 -52.3954552488 -74.7660585647 -inf -38.8301617032 -38.8298749214 -31.7696683961 -31.3117933451 -36.9995355126 -41.3861101309 -34.8800173002 -40.3026039074 -30.0588985426 -38.5553138673 -46.3571782011 -inf -41.8165443735 -36.3384982415 -40.3218526112 -33.2329646265 -30.4183848104 -39.6010692759 -inf -47.2899360084 -26.498416528 -32.533222573 -32.3373445514 -43.9169184189 -68.7322243085 -39.8622076201 -31.3509527797 -33.4232594833 -39.3245210114 -41.274421809 -47.2763128153 -47.304108082 -41.2568490705 -49.1083851431 -37.9060880919 -44.921441094 -53.5161512675 -51.8181549547 -50.2851726453 -45.9239468009 -42.8303107995 -39.1417820864 -35.9768731403 -47.5853195481 -inf -52.6676454136 -32.355333095 -38.988468437 -39.2406946184 -53.4239598923 -75.6887563193 -44.4410296908 -36.4443371409 -40.956991841 -38.5417746032 -44.7782018929 -49.4486282525 -49.9166194154 -40.7537643824 -52.3061425361 -36.402617805 -44.9250838435 -52.4704182718 -53.0802586972 -49.7816777251 -49.0486940811 -47.6636926048 -39.6767133082 -36.4719240362 -53.376432088 -inf -53.8079246492 -35.6180246718 -41.3420565247 -39.2880743734 -53.1819862182 -73.805116472 -46.7327528444 -38.1138932015 -42.4602576378 -39.6490695086 -33.6990859801 -37.9927849165 -43.0925894615 -38.9928644484 -41.1899695044 -31.7982800792 -37.4976743358 -48.1648425331 -40.5267665159 -44.5800351702 -39.875294208 -39.0796124177 -34.1783489717 -33.7212883013 -40.9737974014 -inf -47.5153990818 -27.0886951943 -33.310915606 -38.0057087532 -42.4919605192 -68.0767188339 -39.1287462446 -32.7323376019 -33.7820331415 -37.2701012523 -40.4266640957 -47.4719962157 -47.8615157809 -39.3584212054 -inf -38.1127969737 -46.0495445819 -51.9008902076 -inf -47.8944696272 -43.5244155467 -39.3226834771 -39.1604062687 -35.0557691988 -43.2061510437 -inf -50.4932862083 -29.327583042 -38.7944325142 -37.0357353775 -inf -74.9582914328 -37.2332204262 -35.1402590568 -39.3850133123 -37.4983274272 -inf -38.2608023503 -44.3656812011 -37.9952223258 -inf -37.8567501232 -42.0093081199 -51.1041301261 -inf -inf -inf -inf -36.0807963982 -37.975467836 -inf -43.4880551494 -53.4893371042 -30.6146624521 -41.5295620896 -39.6537364404 -inf -inf -41.0905777927 -inf -36.4433891274 -29.904808582 -31.6894453635 -35.4246914565 -38.2495244137 -31.7893910769 -39.4429053088 -27.3665448649 -34.6231611691 -45.3057245904 -44.3825786656 -41.2486450249 -39.0618834526 -40.9080542595 -33.601149491 -27.8751809529 -38.4195530869 -inf -45.5972369621 -26.4228048513 -29.8153209977 -30.1508789966 -42.0965632898 -67.5148828746 -inf -30.7599479339 -34.551034936 -37.4890918153 -38.2428461146 -43.7628510194 -45.2783704703 -39.1204606837 -46.8288932051 -34.7351577697 -43.2938622852 -51.8105116017 -50.6181940966 -45.3571454491 -43.4228749144 -42.7497211148 -36.2274239324 -36.2096361333 -46.4046074449 -48.7476071256 -50.8314293915 -29.5887536337 -36.1879396412 -37.3979117913 -50.474799113 -72.7778598758 -45.1869789435 -34.0213852155 -41.297475979 -26.6160938528 -28.2064909587 -30.6200919278 -38.5325455669 -29.8671265323 -33.6825233984 -25.519663059 -30.7669107066 -41.2746980836 -inf -39.6594587559 -33.7156294013 -36.9897817164 -24.9087501739 -26.3204223854 -35.5659444508 -inf -40.885773384 -18.4387081421 -27.2122870843 -27.0460680369 -inf -63.7204308907 -29.1981459446 -26.6606202058 -31.2413522505 -36.9357620959 -35.8269317344 -39.4345405885 -42.5912334449 -41.0427885778 -42.999645152 -32.2884711473 -40.839902475 -53.2189364146 -42.1520484344 -46.5276535549 -41.3394616831 -41.1635481003 -35.4639190623 -32.7587335539 -43.7354564715 -37.3262069221 -50.2657792258 -27.9690098755 -34.8257932589 -42.0837164759 -47.5121900345 -75.294439331 -40.0502867829 -37.66249895 -35.7639024478 -35.671148991 -37.8752684777 -inf -43.7849904883 -37.53658678 -inf -38.3252308873 -44.4126491825 -49.1139721612 -48.1297079432 -48.6621809504 -41.6580532843 -45.3216624767 -34.6358901755 -33.6786580286 -inf -inf -49.9798099866 -32.6184731488 -40.9684234263 -39.5881346961 -47.5954466988 -inf -42.4753492709 -37.2862233389 -38.2981642303 -55.1442531148 -57.6100547105 -65.2762133321 -63.3224767798 -56.5612912122 -65.9769944395 -54.6260299317 -59.904657039 -72.1964163568 -66.5099484951 -64.3644487739 -61.8803617574 -63.6506097572 -55.2216541529 -51.6790229993 -65.2375060302 -inf -69.9459213241 -48.6355040126 -54.4642400224 -58.7554543008 -inf -inf -58.4853461216 -52.9205434423 -54.9920058616 -36.5044358234 -inf -inf -inf -38.4633100034 -inf -38.2435818582 -inf -49.5835179663 -inf -inf -49.1040906499 -inf -38.5515239899 -36.0241235095 -inf -inf -53.948928139 -inf -inf -39.1125813994 -inf -inf -39.4405275843 -38.0287497022 -inf -30.9023289519 -32.5192015326 -35.8235733967 -39.2103695617 -34.1941537813 -39.418620265 -28.386820665 -36.5467278515 -51.8241844612 -inf -39.8662746931 -35.3204092834 -37.3129964969 -29.7920142608 -31.1644073447 -41.0312707673 -inf -44.7565311817 -25.8358364562 -28.9919424886 -32.6919189111 -39.8618337244 -67.0047463345 -35.8907501957 -36.139268704 -30.680410119 -31.58727548 -36.4574828918 -38.6430026226 -42.1555162104 -34.8746634222 -40.9684890766 -32.0871637575 -40.110922736 -44.6109425952 -inf -43.299582525 -38.8915492017 -inf -31.1500254171 -31.0172430293 -44.6727208651 -inf -48.3128144343 -27.3494007873 -30.8436511118 -33.0284839594 -43.2743021576 -71.0565515149 -inf -30.0317820141 -27.8666616383", 
        "=="
       ]
      }, 
      {
       "output_type": "stream", 
       "stream": "stderr", 
       "text": [
        "/Users/amit/software/pgmPy/FactorOperations.py:637: RuntimeWarning: divide by zero encountered in log", 
        "  return Factor ( F.getVar().tolist(), F.getCard().tolist(), np.log ( F.getVal() ).tolist(), F.getName() )"
       ]
      }
     ], 
     "prompt_number": 2
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "np.log(0)"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "stream", 
       "stream": "stderr", 
       "text": [
        "-c:1: RuntimeWarning: divide by zero encountered in log"
       ]
      }, 
      {
       "output_type": "pyout", 
       "prompt_number": 3, 
       "text": [
        "-inf"
       ]
      }
     ], 
     "prompt_number": 3
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "run 'testComputeExactMaxMarginalsBP.py'"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "stream", 
       "stream": "stderr", 
       "text": [
        "A factor is empty!", 
        "A factor is empty!", 
        "A factor is empty!", 
        "A factor is empty!", 
        "A factor is empty!", 
        "A factor is empty!", 
        "A factor is empty!", 
        "FactorMarginalization:Error, resultant factor has empty scope...", 
        "/Users/amit/software/pgmPy/FactorOperations.py:637: RuntimeWarning: divide by zero encountered in log", 
        "  return Factor ( F.getVar().tolist(), F.getCard().tolist(), np.log ( F.getVal() ).tolist(), F.getName() )"
       ]
      }, 
      {
       "output_type": "stream", 
       "stream": "stdout", 
       "text": [
        "name: None", 
        "var: 1", 
        "card: 26.0", 
        "val: -31.5460197938 -39.7524576904 -25.6410830409 -31.6260420449 -23.9852567893 -27.030449055 -25.5612346626 -38.1616620023 -25.1067542749 -39.1214447933 -33.6940963515 -24.2523729478 -31.5954467101 -31.3682501411 -26.7882949 -28.529930115 -37.5107846259 -21.1255777759 -29.5699738774 -18.4387080435 -31.1088223882 -29.6385309627 -47.3101027442 -32.9539706865 -25.4958805312 -27.5195883588", 
        "", 
        "name: None", 
        "var: 2", 
        "card: 26.0", 
        "val: -24.1894678825 -42.9441538172 -33.898191327 -36.9655259209 -22.1046749327 -39.6734091935 -33.374687077 -41.9232967566 -57.5500272082 -52.8897719816 -43.1097511664 -49.6241758881 -33.5539271656 -31.4233216513 -18.4387080435 -32.7436750839 -56.6634843105 -33.384140013 -29.4067884074 -35.2860205717 -27.2920916131 -40.5064836334 -63.824446184 -38.5848385023 -30.0472785068 -38.0127586151", 
        "", 
        "name: None", 
        "var: 3", 
        "card: 26.0", 
        "val: -31.739547823 -42.1583147854 -36.6800631208 -42.3228103428 -29.0969258994 -24.3849102986 -28.6446742201 -46.7233592452 -43.0751780236 -57.2075263092 -41.0441273426 -33.8063259907 -52.9646680046 -52.2220409068 -33.0208395462 -18.4387080435 -41.7297174472 -26.4641246754 -34.248693291 -29.1116391601 -42.1497961452 -41.9224857015 -67.8473514714 -36.1175354042 -32.9592667817 -31.5488612698", 
        "", 
        "name: None", 
        "var: 4", 
        "card: 26.0", 
        "val: -23.4040753043 -34.5177339447 -33.1762592909 -32.4028531682 -20.4284830391 -30.9055386866 -27.8457755476 -31.512251295 -44.6311728838 -45.0933793954 -33.9288067136 -39.4881061239 -20.7709475888 -24.5027078456 -18.4387080435 -19.6615850745 -47.7336045586 -27.211058663 -34.1608487715 -24.0538666294 -29.8533618378 -41.4729306385 -38.8117373668 -37.491666585 -26.7970885195 -32.5125862214", 
        "", 
        "name: None", 
        "var: 5", 
        "card: 26.0", 
        "val: -23.0660898305 -35.9544696368 -26.2981526122 -29.6717399084 -21.7147100384 -36.0819105494 -25.7366801549 -40.5348402425 -57.1879692201 -46.7451686545 -36.0054896857 -45.8435578716 -32.4051297959 -22.7796593505 -18.4387080435 -30.6392285486 -41.2680676992 -30.2179035078 -27.7544392596 -29.5566809342 -24.0229686973 -36.2074545764 -57.2945579326 -41.8279563202 -28.3121375628 -38.1421921137", 
        "", 
        "name: None", 
        "var: 6", 
        "card: 26.0", 
        "val: -26.6160938067 -28.2064908833 -30.620091888 -37.9442968051 -29.867126482 -33.6825233307 -25.5196630409 -30.7669107061 -41.2746980483 -37.9809203834 -38.0827386725 -33.7156293685 -34.7729269315 -24.908750093 -26.320422326 -35.5659443621 -37.3262069087 -40.8857733491 -18.4387080435 -27.2122870109 -27.046068006 -36.4304427635 -63.7204308164 -29.1981459351 -26.6606201814 -27.8666616219", 
        "", 
        "name: None", 
        "var: 7", 
        "card: 26.0", 
        "val: -28.3660824395 -40.8008133056 -26.9845806521 -33.2353486195 -23.1516528797 -27.6883668259 -28.8825648423 -38.5415696476 -26.5858020686 -41.3847658604 -30.6930836159 -26.4984164789 -32.3553330243 -35.6180246281 -27.0886951193 -29.3275830031 -30.6146623885 -26.4228048497 -29.5887536108 -18.4387080435 -27.9690098558 -32.6184730957 -48.6355039829 -36.0241234633 -25.8358363816 -27.3494007434"
       ]
      }
     ], 
     "prompt_number": 1
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "run 'testMaxDecoding.py'"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "stream", 
       "stream": "stdout", 
       "text": [
        "['t', 'o', 'p', 'o', 'o', 's', 't']"
       ]
      }
     ], 
     "prompt_number": 9
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "from Factor import *", 
      "from PGMcommon import *", 
      "from CliqueTree import *", 
      "from CliqueTreeOperations import *", 
      "from FactorOperations import *", 
      "import scipy.io as sio", 
      "import numpy as np", 
      "", 
      "matfile='/Users/amit/BC_Classes/PGM/Prog4/PA4Sample.mat'", 
      "mat_contents=sio.loadmat(matfile)", 
      "", 
      "mat_struct=mat_contents['SixPersonPedigree']", 
      "val=mat_struct[0]", 
      "", 
      "originalFactorList=[]", 
      "for elem in val:", 
      "    ", 
      "    (var, card, val) =elem", 
      "    f= Factor( var[0].tolist(), card[0].tolist(), val[0].tolist(), 'factor' )", 
      "    ", 
      "    originalFactorList.append(f)", 
      "", 
      "print ComputeMarginal([5],originalFactorList, [1,1])", 
      "M=ComputeExactMarginalsBP(originalFactorList, [1], 0)"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "stream", 
       "stream": "stdout", 
       "text": [
        "name: None", 
        "var: 5", 
        "card: 3.0", 
        "val: 0.055 0.54 0.405"
       ]
      }, 
      {
       "output_type": "stream", 
       "stream": "stderr", 
       "text": [
        "A factor is empty!", 
        "A factor is empty!", 
        "A factor is empty!", 
        "A factor is empty!", 
        "A factor is empty!", 
        "A factor is empty!", 
        "A factor is empty!", 
        "A factor is empty!", 
        "A factor is empty!", 
        "A factor is empty!", 
        "A factor is empty!", 
        "A factor is empty!", 
        "FactorMarginalization:Error, resultant factor has empty scope..."
       ]
      }
     ], 
     "prompt_number": 1
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "for m in  M:", 
      "    print m", 
      "    print"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "stream", 
       "stream": "stdout", 
       "text": [
        "name: None", 
        "var: 1", 
        "card: 3.0", 
        "val: 1.0 0.0 0.0", 
        "", 
        "name: None", 
        "var: 2", 
        "card: 3.0", 
        "val: 0.1 0.9 0.0", 
        "", 
        "name: None", 
        "var: 3", 
        "card: 3.0", 
        "val: 0.01 0.18 0.81", 
        "", 
        "name: None", 
        "var: 4", 
        "card: 3.0", 
        "val: 0.1 0.9 0.0", 
        "", 
        "name: None", 
        "var: 5", 
        "card: 3.0", 
        "val: 0.055 0.54 0.405", 
        "", 
        "name: None", 
        "var: 6", 
        "card: 3.0", 
        "val: 0.01 0.18 0.81", 
        "", 
        "name: None", 
        "var: 7", 
        "card: 2.0", 
        "val: 0.8 0.2", 
        "", 
        "name: None", 
        "var: 8", 
        "card: 2.0", 
        "val: 0.62 0.38", 
        "", 
        "name: None", 
        "var: 9", 
        "card: 2.0", 
        "val: 0.197 0.803", 
        "", 
        "name: None", 
        "var: 10", 
        "card: 2.0", 
        "val: 0.62 0.38", 
        "", 
        "name: None", 
        "var: 11", 
        "card: 2.0", 
        "val: 0.4085 0.5915", 
        "", 
        "name: None", 
        "var: 12", 
        "card: 2.0", 
        "val: 0.197 0.803"
       ]
      }
     ], 
     "prompt_number": 2
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "print ComputeMarginal(5,originalFactorList, [1,1])"
     ], 
     "language": "python", 
     "outputs": [
      {
       "ename": "TypeError", 
       "evalue": "'int' object is not iterable", 
       "output_type": "pyerr", 
       "traceback": [
        "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m\n\u001b[0;31mTypeError\u001b[0m                                 Traceback (most recent call last)", 
        "\u001b[0;32m/Users/amit/software/pgmPy/PythonNotebooks/<ipython-input-3-3368f3269e7b>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0;32mprint\u001b[0m \u001b[0mComputeMarginal\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m5\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0moriginalFactorList\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", 
        "\u001b[0;32m/Users/amit/software/pgmPy/FactorOperations.pyc\u001b[0m in \u001b[0;36mComputeMarginal\u001b[0;34m(V, F, E)\u001b[0m\n\u001b[1;32m    366\u001b[0m     \u001b[0;31m#print union_variables\u001b[0m\n\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    367\u001b[0m     \u001b[0;31m#v contains the variables not in the list of variables in the marginal\u001b[0m\n\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 368\u001b[0;31m     \u001b[0mv\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mlist\u001b[0m\u001b[0;34m(\u001b[0m \u001b[0munion_variables\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdifference\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mV\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m    369\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    370\u001b[0m     \u001b[0;31m# compute the joint distribution, but then reduce it, given the evidence\u001b[0m\n\u001b[0;34m\u001b[0m\u001b[0m\n", 
        "\u001b[0;31mTypeError\u001b[0m: 'int' object is not iterable"
       ]
      }
     ], 
     "prompt_number": 3
    }, 
    {
     "cell_type": "code", 
     "collapsed": true, 
     "input": [
      "# question regarding ComputeExactMarginalsBP", 
      "# 1. one set of factors is in Log space", 
      "# 2. while anotoher set of factors is not", 
      "# 3. need to be consistent", 
      "", 
      "# Next question, regarding evidence observed.", 
      "# regarding the GLF factor, we observe the pileiup base calls", 
      "# but we don't observe is the actually genotype", 
      "# now if we observed the genotype, then the GLF would be restricted", 
      "", 
      "# play around with the toy SixPerson pedigree network for genetic cousesling in PA2 and PA4.", 
      "", 
      "", 
      "#Last question: how is your clicque tree looking? We have nodes of the clique tree", 
      "# each variable is assigned to a node and the resulting tree must have ", 
      "#running intersection property"
     ], 
     "language": "python", 
     "outputs": [], 
     "prompt_number": 1
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "from PedigreeFactors import *", 
      "from FactorOperations import *", 
      "from GeneticNetworkFactory import *", 
      "from CliqueTree import *", 
      "import networkx as nx", 
      "import matplotlib.pyplot as plt", 
      "from CliqueTreeOperations import *", 
      "#to create a clique tree, we start with a list of factors                                                                                                           ", 
      "#and potentially some observed evidence                                                                                                                             ", 
      "alphaList=[.8,.6,.1]", 
      "allelefreq=[.1,.9]", 
      "chrom='12'", 
      "position=1000", 
      "g1=GeneticNetworkFactory('sixperson.ped',alphaList,allelefreq, chrom,position)", 
      "g1.constructNetwork()", 
      "factorList=g1.getFactorList()"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "stream", 
       "stream": "stdout", 
       "text": [
        "[<PedigreeFactors.GenotypeAlleleFreqFactor object at 0x10493ac90>, <PedigreeFactors.GenotypeGivenParentsFactor object at 0x10493ad90>, <PedigreeFactors.GenotypeAlleleFreqFactor object at 0x10493aed0>, <PedigreeFactors.GenotypeGivenParentsFactor object at 0x10493a850>, <PedigreeFactors.GenotypeGivenParentsFactor object at 0x10494e150>, <PedigreeFactors.GenotypeAlleleFreqFactor object at 0x10494e290>, <PedigreeFactors.PhenotypeGivenGenotypeFactor object at 0x10493ad10>, <PedigreeFactors.PhenotypeGivenGenotypeFactor object at 0x10493ae90>, <PedigreeFactors.PhenotypeGivenGenotypeFactor object at 0x10493af90>, <PedigreeFactors.PhenotypeGivenGenotypeFactor object at 0x10494e0d0>, <PedigreeFactors.PhenotypeGivenGenotypeFactor object at 0x10494e210>, <PedigreeFactors.PhenotypeGivenGenotypeFactor object at 0x10494e350>]"
       ]
      }
     ], 
     "prompt_number": 1
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "V=getUniqueVar(factorList)", 
      "print V", 
      "totalVars=len(V)", 
      "cardinality=np.zeros(len(V)).tolist()", 
      "for i in range(len(V)):", 
      "    for j in range(len(factorList)):", 
      "        try:", 
      "            indx= factorList[j].getVar().tolist().index( V[i] )", 
      "            cardinality[i]=factorList[j].getCard().tolist()[indx]", 
      "            break", 
      "        except:", 
      "            continue", 
      "", 
      "edges=np.zeros( (totalVars, totalVars))", 
      "", 
      "", 
      "", 
      "for f in factorList:", 
      "    variableList=f.getVar()", 
      "    print variableList", 
      "    for j in range(len(variableList) ):", 
      "        for k in range (len(variableList) ):", 
      "            edges[ variableList[j]-1, variableList[k]-1 ]=1", 
      "print edges"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "stream", 
       "stream": "stdout", 
       "text": [
        "[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]", 
        "[1]", 
        "[2 1 3]", 
        "[3]", 
        "[4 1 3]", 
        "[5 2 6]", 
        "[6]", 
        "[7 1]", 
        "[8 2]", 
        "[9 3]", 
        "[10  4]", 
        "[11  5]", 
        "[12  6]", 
        "[[ 1.  1.  1.  1.  0.  0.  1.  0.  0.  0.  0.  0.]", 
        " [ 1.  1.  1.  0.  1.  1.  0.  1.  0.  0.  0.  0.]", 
        " [ 1.  1.  1.  1.  0.  0.  0.  0.  1.  0.  0.  0.]", 
        " [ 1.  0.  1.  1.  0.  0.  0.  0.  0.  1.  0.  0.]", 
        " [ 0.  1.  0.  0.  1.  1.  0.  0.  0.  0.  1.  0.]", 
        " [ 0.  1.  0.  0.  1.  1.  0.  0.  0.  0.  0.  1.]", 
        " [ 1.  0.  0.  0.  0.  0.  1.  0.  0.  0.  0.  0.]", 
        " [ 0.  1.  0.  0.  0.  0.  0.  1.  0.  0.  0.  0.]", 
        " [ 0.  0.  1.  0.  0.  0.  0.  0.  1.  0.  0.  0.]", 
        " [ 0.  0.  0.  1.  0.  0.  0.  0.  0.  1.  0.  0.]", 
        " [ 0.  0.  0.  0.  1.  0.  0.  0.  0.  0.  1.  0.]", 
        " [ 0.  0.  0.  0.  0.  1.  0.  0.  0.  0.  0.  1.]]"
       ]
      }
     ], 
     "prompt_number": 6
    }, 
    {
     "cell_type": "code", 
     "collapsed": true, 
     "input": [
      "import numpy as np", 
      "", 
      "phiLog=np.array ( [ -21.3629340588, -31.7739068729, -29.9338300704, -31.5159041042, -19.3717644316, -26.5334172783, -23.3150836723, -31.6492202004, -52.3504210279, -39.6312970241, -32.1334137988, -45.6962328419, -13.9988360129, -15.2420089143, -19.227018512, -23.6088962795, -31.402884695, -26.5864372903, -27.0355390388, -24.2961312011, -25.1201055629, -25.2138758101, -30.4684184389, -27.9820530362, -27.278783612, -29.0268887873] )", 
      "phi=np.exp(phiLog)"
     ], 
     "language": "python", 
     "outputs": [], 
     "prompt_number": 3
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "print phi"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "stream", 
       "stream": "stdout", 
       "text": [
        "[  5.27467397e-10   1.58769683e-14   9.99776164e-14   2.05502332e-14", 
        "   3.86322144e-09   2.99697617e-12   7.48837899e-11   1.79853258e-14", 
        "   1.83865828e-23   6.14251735e-18   1.10824480e-14   1.42684972e-20", 
        "   8.32497171e-07   2.40148366e-07   4.46490226e-09   5.58195874e-11", 
        "   2.30091439e-14   2.84221542e-12   1.81390518e-12   2.80752924e-11", 
        "   1.23162010e-11   1.12138016e-11   5.85779272e-14   7.03961283e-13", 
        "   1.42224627e-12   2.47618092e-13]"
       ]
      }
     ], 
     "prompt_number": 4
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "np.exp(-21.3629 )"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "pyout", 
       "prompt_number": 5, 
       "text": [
        "5.2748536238316102e-10"
       ]
      }
     ], 
     "prompt_number": 5
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "np.log(.24)"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "pyout", 
       "prompt_number": 6, 
       "text": [
        "-1.4271163556401458"
       ]
      }
     ], 
     "prompt_number": 6
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "print phiLog"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "stream", 
       "stream": "stdout", 
       "text": [
        "[-21.36293406 -31.77390687 -29.93383007 -31.5159041  -19.37176443", 
        " -26.53341728 -23.31508367 -31.6492202  -52.35042103 -39.63129702", 
        " -32.1334138  -45.69623284 -13.99883601 -15.24200891 -19.22701851", 
        " -23.60889628 -31.4028847  -26.58643729 -27.03553904 -24.2961312", 
        " -25.12010556 -25.21387581 -30.46841844 -27.98205304 -27.27878361", 
        " -29.02688879]"
       ]
      }
     ], 
     "prompt_number": 7
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "def lognormalize(x):", 
      "    a=np.logaddexp.reduce(x)", 
      "    return np.exp(x-a)", 
      "", 
      "phiNormalized=lognormalize(phiLog)", 
      "print np.sum(phiNormalized)", 
      "print phiNormalized"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "stream", 
       "stream": "stdout", 
       "text": [
        "1.0", 
        "[  4.87631010e-04   1.46778779e-08   9.24269184e-08   1.89981998e-08", 
        "   3.57145595e-03   2.77063289e-06   6.92282752e-05   1.66270042e-08", 
        "   1.69979567e-17   5.67861058e-12   1.02454585e-08   1.31908848e-14", 
        "   7.69623751e-01   2.22011428e-01   4.12769550e-03   5.16038753e-05", 
        "   2.12714040e-08   2.62756027e-06   1.67691201e-06   2.59549372e-05", 
        "   1.13860337e-05   1.03668917e-05   5.41538946e-08   6.50795392e-07", 
        "   1.31483271e-06   2.28917012e-07]"
       ]
      }
     ], 
     "prompt_number": 12
    }, 
    {
     "cell_type": "code", 
     "collapsed": false, 
     "input": [
      "print phiLog"
     ], 
     "language": "python", 
     "outputs": [
      {
       "output_type": "stream", 
       "stream": "stdout", 
       "text": [
        "[-21.36293406 -31.77390687 -29.93383007 -31.5159041  -19.37176443", 
        " -26.53341728 -23.31508367 -31.6492202  -52.35042103 -39.63129702", 
        " -32.1334138  -45.69623284 -13.99883601 -15.24200891 -19.22701851", 
        " -23.60889628 -31.4028847  -26.58643729 -27.03553904 -24.2961312", 
        " -25.12010556 -25.21387581 -30.46841844 -27.98205304 -27.27878361", 
        " -29.02688879]"
       ]
      }
     ], 
     "prompt_number": 13
    }, 
    {
     "cell_type": "code", 
     "collapsed": true, 
     "input": [
      "# ComputeExactMarginalsBP for max-marginals for MAP assignment does so in log-space", 
      "# The code does not re-exponentiate the values", 
      "# Note, then when computing the genotype log-likelihoods and passing this factor", 
      "# along with the list of factors to construct the pgmNetwork, we need to make sure", 
      "# to convert the numbers back into probablity space", 
      "# page 360 in Koller and Friedman talks about this", 
      "", 
      "# I've added a function lognormalize in PGMcommon.py that normalizes log-proablities and then", 
      "# returns the values in probablity space"
     ], 
     "language": "python", 
     "outputs": []
    }
   ]
  }
 ]
}